in reply to An efficient way to parallelize loops
Also there are some things you can improve within the loop before investigating parallelism.
For one you can look up $categories{$k}->{traces} once outside the whole loop.
It might also be much faster to join all those regexes together to a single regex and match it once, instead of iterating over the regexes (Don't know if that works in your case).
Also you seem to read the whole file into memory first, and then iterate over it - that's rather inefficient. Instead use
OUTER: while(my $line = <GZIP>) { ...
to read it line by line.
Parallelization is usually a lot of trouble, so try the conventional optimization wisdom first.
(Update: removed one comment that's not applicable; added hint aboute memory usage).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: An efficient way to parallelize loops
by JavaFan (Canon) on Jun 01, 2010 at 10:05 UTC | |
|
Re^2: An efficient way to parallelize loops
by Deus Ex (Scribe) on Jun 01, 2010 at 09:25 UTC | |
by moritz (Cardinal) on Jun 01, 2010 at 09:36 UTC | |
by Deus Ex (Scribe) on Jun 01, 2010 at 10:18 UTC | |
by Deus Ex (Scribe) on Jun 01, 2010 at 13:23 UTC | |
|
Re^2: An efficient way to parallelize loops
by Deus Ex (Scribe) on Jun 01, 2010 at 12:51 UTC | |
by marto (Cardinal) on Jun 01, 2010 at 13:08 UTC | |
by Deus Ex (Scribe) on Jun 01, 2010 at 13:28 UTC | |
by marto (Cardinal) on Jun 01, 2010 at 13:32 UTC |