Update: Added serial code. Am happy that IO in MCE is not too far behind. One day, will try another technique. IO aside, any CPU intensive operations such as regex do benefit from running with multiple workers.
Yes, IO will only go as fast as the underlying IO capabilities. MCE does sequential IO, meaning only one worker reads at any given time. The regex operation benefits from having multiple workers. Eventually, IO becomes the bottleneck.
1 worker: 9.437 secs. 2 workers: 4.480 secs. 3 workers: 3.248 secs. 4 workers: 3.236 secs. 8 workers: 3.240 secs.
Below, removed counting and regex from the equation and running with 1 worker. It completes as fast as IO allows in 3.256 seconds.
mce_flow_f { chunk_size => '24m', max_workers => 1, use_slurpio => 1, }, sub { }, 'Dictionary2GB.txt';
The following serial code, reader only and without MCE, takes 2.864 seconds to read directly from the PCIe-based SSD drive, not from FS cache.
use strict; use warnings; my $size = 24 * 1024 * 1024; open my $fh, '<', 'Dictionary2GB.txt' or die "$!"; while ( read( $fh, my $b, $size ) ) { $b .= <$fh>; } close $fh;
In reply to Re^3: How to optimize a regex on a large file read line by line ?
by marioroy
in thread How to optimize a regex on a large file read line by line ?
by John FENDER
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |