2009-07-06 34 views
13

Mô-đun tốt nhất cho quy trình song song trong Perl là gì? Tôi chưa bao giờ thực hiện xử lý song song trong Perl.Mô-đun tốt nhất để xử lý song song trong Perl là gì?

Mô-đun Perl tốt cho quy trình song song nào sẽ được sử dụng trong truy cập và gửi thư DB?

Tôi đã xem mô-đun Parallel::ForkManager. Bất kỳ ý tưởng đánh giá cao.

+5

Bạn có muốn song song mã CPU hoặc mã ràng buộc IO không? – jrockway

Trả lời

13

Parallel::ForkManager, như POD cho biết, có thể giới hạn số lượng quy trình được chia nhỏ. Sau đó, bạn có thể sử dụng trẻ em để làm bất kỳ công việc nào. Tôi nhớ sử dụng mô-đun cho trình tải xuống.

12

Vâng, tất cả phụ thuộc vào trường hợp cụ thể. Tùy thuộc vào chính xác những gì bạn cần để đạt được, bạn có thể được tốt hơn với một trong những sau:

Đối với một số nhiệm vụ cũng có module chuyên ngành - cho ví dụ LWP::Parallel::UserAgent, về cơ bản có nghĩa là - bạn phải cung cấp cho chúng tôi nhiều chi tiết hơn về những gì bạn muốn đạt được để có được câu trả lời tốt nhất có thể.

7

Công cụ đa lõi cho Perl (MCE) đã được đăng trên CPAN.

http://code.google.com/p/many-core-engine-perl/

https://metacpan.org/module/MCE

MCE đi kèm với ví dụ khác nhau cho thấy thực tế kịch bản trường hợp sử dụng trên parallelizing một cái gì đó nhỏ như con mèo (thử với -n) để greping cho các mẫu và số lượng từ tập hợp.

barrier_sync.pl 
      A barrier sync demonstration. 

cat.pl Concatenation script, similar to the cat binary. 
egrep.pl Egrep script, similar to the egrep binary. 
wc.pl  Word count script, similar to the wc binary. 

findnull.pl 
      A parallel driven script to report lines containing 
      null fields. It is many times faster than the binary 
      egrep command. Try against a large file containing 
      very long lines. 

flow_model.pl 
      Demonstrates MCE::Flow, MCE::Queue, and MCE->gather. 

foreach.pl, forseq.pl, forchunk.pl 
      These take the same sqrt example from Parallel::Loops 
      and measures the overhead of the engine. The number 
      indicates the size of @input which can be submitted 
      and results displayed in 1 second. 

      Parallel::Loops:  600 Forking each @input is expensive 
      MCE foreach....: 34,000 Sends result after each @input 
      MCE forseq.....: 70,000 Loops through sequence of numbers 
      MCE forchunk...: 480,000 Chunking reduces overhead 

interval.pl 
      Demonstration of the interval option appearing in MCE 1.5. 

matmult/matmult_base.pl, matmult_mce.pl, strassen_mce.pl 
      Various matrix multiplication demonstrations benchmarking 
      PDL, PDL + MCE, as well as parallelizing Strassen 
      divide-and-conquer algorithm. Also included are 2 plain 
      Perl examples. 

scaling_pings.pl 
      Perform ping test and report back failing IPs to 
      standard output. 

seq_demo.pl 
      A demonstration of the new sequence option appearing 
      in MCE 1.3. Run with seq_demo.pl | sort 

tbray/wf_mce1.pl, wf_mce2.pl, wf_mce3.pl 
      An implementation of wide finder utilizing MCE. 
      As fast as MMAP IO when file resides in OS FS cache. 
      2x ~ 3x faster when reading directly from disk. 
Các vấn đề liên quan