So, I run perl 5.10 on the 2 duo macbook pro core compiled with threading support: usethreads=define, useithreads=define. I have a simple script to read 4 gzipped files containing aroud 750,000 lines each. I am using Compress :: Zlib to perform file compression and reading. I have 2 implementation, the only difference between them use threads. In addition, both scripts execute the same subroutine for reading. Therefore, in psuedocode, a program without streaming does the following:
usethreads=define
useithreads=define
use threads
read_gzipped(file1); read_gzipped(file2); read_gzipped(file3); read_gzipped(file4);
The threaded version is as follows:
my thr0 = threads->new(\$read_gzipped,'file1') my thr1 = threads->new(\$read_gzipped,'file1') my thr2 = threads->new(\$read_gzipped,'file1') my thr3 = threads->new(\$read_gzipped,'file1') thr0->join() thr1->join() thr2->join() thr3->join()
2 , -threaded script. , , . - , ?
- GZIP - . , platter, . . , , .
, , IO-, . -, script.
ithreads , -, . cpu.
Parallel::ForkManager.
- Perl .
, /, top, . depesz, , / ( ), , .
top
, /, , [1] - 100%, / - , , , .
[1] , , , , make , , , . , , , , , . , . I/O ( - , // -), .
make
Source: https://habr.com/ru/post/1722335/More articles:Running numbers in SQL - sqlText editor for Ruby-on-Rails - ruby | fooobar.comУсреднение общего количества в mySQL - mysqlJava library size - javaRestricting access to the Wpf trap for a list - validationHow can I eliminate development-time packages in Delphi / C ++ Builder? - delphiOverhead for calling a procedure / function in another Oracle package - oracleGet Twitter Followers - twitterHow do WPF Markup extensions extend compilation errors? - c #Ivy, ant and run scripts - javaAll Articles