Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

File::Temp painfully slow under Cygwin

by dds (Novice)
on Jul 09, 2013 at 09:13 UTC ( #1043274=perlquestion: print w/replies, xml ) Need Help??
dds has asked for the wisdom of the Perl Monks concerning the following question:

The following command sometimes takes as much as half a minute to run under Cygwin (1-7.19-1) and perl 5, version 14, subversion 2 (v5.14.2) built for cygwin-thread-multi-64int on an otherwise idle system with 16GB of RAM and an 8-core CPU running Windows 7.
$ time /usr/bin/perl -e 'use File::Temp' real 0m38.796s user 0m0.109s sys 0m0.124s
The second time it is executed it is typically considerably faster.
$ time /usr/bin/perl -e 'use File::Temp' real 0m2.498s user 0m0.124s sys 0m0.124s

I have run the command under strace to see if there was a particular system call that takes a long time to execute, but a cursory examination of the output didn't show me such a culprit.

I also looked at the time when each included file is opened, and I see that they are evenly spread out, with some however (warnings, Cwd, Config, Basename, constant) taking more than a second to load.

$ awk '/open: open/{print $2 / 1e6, $7}' strace.out 0.062687 open(/dev/urandom, 0.093652 open(/dev/urandom, 0.162175 open(/dev/null, 0.332337 open(/usr/lib/perl5/5.14/File/, 0.413667 open(/usr/lib/perl5/5.14/, 0.574798 open(/usr/lib/perl5/5.14/, 0.647806 open(/usr/lib/perl5/5.14/, 2.12777 open(/usr/lib/perl5/5.14/, 2.40747 open(/usr/lib/perl5/5.14/i686-cygwin-threads-64int/File/Spec.p +m, 2.48178 open(/usr/lib/perl5/5.14/, 2.56121 open(/usr/lib/perl5/5.14/warnings/, 2.83884 open(/usr/lib/perl5/5.14/i686-cygwin-threads-64int/File/Spec/C, 3.06084 open(/usr/lib/perl5/5.14/i686-cygwin-threads-64int/File/Spec/U, 3.59694 open(/usr/lib/perl5/5.14/File/, 3.67258 open(/usr/lib/perl5/5.14/i686-cygwin-threads-64int/, 4.72324 open(/usr/lib/perl5/5.14/, 4.94318 open(/usr/lib/perl5/5.14/i686-cygwin-threads-64int/DynaLoader. +pm, 5.00538 open(/usr/lib/perl5/5.14/i686-cygwin-threads-64int/, 16.219 open(/usr/lib/perl5/5.14/File/, 17.3896 open(/usr/lib/perl5/5.14/i686-cygwin-threads-64int/, 17.7389 open(/usr/lib/perl5/5.14/i686-cygwin-threads-64int/IO/Seekable, 17.8311 open(/usr/lib/perl5/5.14/i686-cygwin-threads-64int/IO/Handle.p +m, 17.9298 open(/usr/lib/perl5/5.14/, 18.1662 open(/usr/lib/perl5/5.14/, 18.2823 open(/usr/lib/perl5/5.14/i686-cygwin-threads-64int/, 19.0989 open(/usr/lib/perl5/5.14/i686-cygwin-threads-64int/, 19.468 open(/usr/lib/perl5/5.14/, 19.8129 open(/usr/lib/perl5/5.14/, 20.236 open(/usr/lib/perl5/5.14/, 22.0238 open(/usr/lib/perl5/5.14/Carp/, 22.1132 open(/usr/lib/perl5/5.14/Exporter/,

Replies are listed 'Best First'.
Re: File::Temp painfully slow under Cygwin
by hdb (Monsignor) on Jul 09, 2013 at 09:29 UTC

    Is this only happening for File::Temp or other modules as well?

      I had no problem with
      use File::Copy; use Getopt::Std; use IO::Handle;
        Get Devel::Trace and try  perl -d:Trace -e ' require File::Temp; ' and try to find where it hangs
Re: File::Temp painfully slow under Cygwin (Cygwin HD)
by Anonymous Monk on Jul 09, 2013 at 09:22 UTC

    Sounds like cygwin+harddisk issue, like not loading an *cough* UDMA driver, which can cripple a win32 system

    or some kind of cygwin induced swapping

    Tough stuff to figure out

      The problem is indeed related to Cygwin. The ActiveState version executes the same code lightningly fast.
      $ time /cygdrive/c/Perl/bin/perl -e 'use File::Temp' real 0m0.212s user 0m0.015s sys 0m0.015s $ /cygdrive/c/Perl/bin/perl -v This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x +86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2012, Larry Wall Binary build 1603 [296746] provided by ActiveState http://www.ActiveSt Built Mar 13 2013 11:29:21
Re: File::Temp painfully slow under Cygwin
by Laurent_R (Canon) on Jul 09, 2013 at 18:49 UTC

    It may not help very much, but I just tried your command under Cygwin, Win 7 and 8 cores (in other words, a configuration very similar to what you have). First call and second one:

    Laurent@Laurent-HP ~ $ time /usr/bin/perl -e 'use File::Temp' real 0m0.763s user 0m0.108s sys 0m0.139s Laurent@Laurent-HP ~ $ time /usr/bin/perl -e 'use File::Temp' real 0m0.164s user 0m0.093s sys 0m0.062s
      Thank you. The problem could then be an installation issue. What do you get by running the following?
      find /usr/lib/perl5/ -name Cwd.dll
      In my case the file does not exist, and this may explain the problem.
        My contribution from a Toshiba NB305 Netbook 1.66GHz with 2GB RAM, running WinXP:
        $ uname -a CYGWIN_NT-5.1 minime 1.7.20(0.266/5/3) 2013-06-07 11:11 i686 Cygwin $ perl -v This is perl 5, version 14, subversion 2 (v5.14.2) built for cygwin-th +read-multi-64int (with 7 registered patches, see perl -V for more detail) Copyright 1987-2011, Larry Wall <output truncated> $ time /usr/bin/perl -e 'use File::Temp' real 0m0.469s user 0m0.358s sys 0m0.125s $ time /usr/bin/perl -e 'use File::Temp' real 0m0.438s user 0m0.249s sys 0m0.202s
        ...and the search for Cwd.dll returned nothing.

        I initially ran this earlier and the "real" time was just over two seconds, but that was the slowest it recorded.

        Hope this helps!

        Does not seem to exist either.

        Laurent@Laurent-HP ~ $ find /usr/lib/perl5/ -name Cwd.dll Laurent@Laurent-HP ~

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1043274]
Approved by Corion
[jdporter]: erix - excellent. thanks! davido - no; just reminiscing. :-)

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2018-06-21 16:55 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (118 votes). Check out past polls.