It turns out this defect has nothing to do with file I/O at all.

The following code can reproduce the effect. I have raised a bug ticket with perlbug and the compiler of perl for cygwin.

## Test code to show split slow when used in muiltiple threads is slow + in cygwin perl use strict; use warnings; use threads; use Thread::Queue; use Time::HiRes(); my $string = "12356789 "x25; my $TASK_COUNT =10; print( (`$^X -v`)[1]); thread_process(1); thread_process(4); sub thread_process { my $parallel = shift; my $start = Time::HiRes::time(); my @threads; my $queue = Thread::Queue->new(); for my $p ( 1 .. $parallel ) { push @threads, threads->create( sub { while( my $task_no = $queue->dequeue) { for my $n (1..10_000) { my @x= split / /, $string; # Split } }}) } $queue->enqueue( 1 .. $TASK_COUNT , (undef) x $parallel ); $_->join for @threads; my $end= Time::HiRes::time(); printf "Processing %d tasks in %d threads completed in %fsecs\n", +$TASK_COUNT, $parallel, $end-$start; } __END__ # Here is an example of the output on my dual core XP machine $ ~/localperl/bin/perl.exe example.split.pl This is perl 5, version 14, subversion 1 (v5.14.1) built for cygwin-th +read-multi-64int Processing 10 tasks in 1 threads completed in 2.640625secs Processing 10 tasks in 4 threads completed in 12.468637secs $ perl example.split.pl This is perl, v5.10.0 built for cygwin-thread-multi-64int Processing 10 tasks in 1 threads completed in 4.578125secs Processing 10 tasks in 4 threads completed in 25.437345secs # The defect does not occur with ActivePerl. Instead the expected slig +htly faster result occurs $ c:/perl/bin/perl example.split.pl This is perl 5, version 12, subversion 3 (v5.12.3) built for MSWin32-x +86-multi-thread Processing 10 tasks in 1 threads completed in 2.062500secs Processing 10 tasks in 4 threads completed in 1.671790secs

In reply to Re: Reading from file in threaded code is slow by amcglinchy
in thread Reading from file in threaded code is slow by amcglinchy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.