develooper Front page | perl.perl5.porters | Postings from June 2016

Re: Inefficient stat-ing of files?

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
June 24, 2016 19:11
Subject:
Re: Inefficient stat-ing of files?
Message ID:
20160624190400.GB17054@iabyn.com
On Thu, Jun 23, 2016 at 10:16:08PM -0400, David Farrell wrote:
> Hi Porters,
> 
> I used strace on a Perl one liner and found that 12% of the time was spent
> stat-ing files like this:
> 
> stat("/home/dfarrell/.plenv/versions/5.22.0/lib/perl5/site_perl/5.22.0/strict.pmc",
> 0x7ffecd546980) = -1 ENOENT (No such file or directory)
> stat("/home/dfarrell/.plenv/versions/5.22.0/lib/perl5/site_perl/5.22.0/
> strict.pm", 0x7ffecd5468b0) = -1 ENOENT (No such file or directory)

Here are the results on my Linux system of 1000 runs starting perl 5.24.0
with a few simple modules: first with the standard @INC (8 stats per
module) and then with a stripped down @INC (2 stats per module). The first
one has a dummy assign to an array to roughly match the overhead of
initialising @INC.

The results (task-clock time elapsed) are indistinguishable - any
difference is noise: I get different numbers re-running the test.
Sometimes one is faster, sometimes slower, with times in the range of
about 5.7-6.4ms for both.


$ perf stat -r 1000 perl5240o -e'BEGIN { @XXX="/home/davem/perl5/a/perl-5.24.0o.out/lib/5.24.0" }  use strict; use warnings; use Exporter ()'
 
 Performance counter stats for 'perl5240o -eBEGIN { @XXX="/home/davem/perl5/a/perl-5.24.0o.out/lib/5.24.0" }  use strict; use warnings; use Exporter ()' (1000 runs):

          6.032405      task-clock (msec)         #    0.937 CPUs utilized            ( +-  0.90% )
                 0      context-switches          #    0.001 K/sec                    ( +- 40.72% )
                 0      cpu-migrations            #    0.000 K/sec                  
               250      page-faults               #    0.041 M/sec                    ( +-  0.02% )
        10,560,354      cycles                    #    1.751 GHz                      ( +-  0.15% )
         5,777,039      stalled-cycles-frontend   #   54.70% frontend cycles idle     ( +-  0.28% )
   <not supported>      stalled-cycles-backend   
        10,422,972      instructions              #    0.99  insns per cycle        
                                                  #    0.55  stalled cycles per insn  ( +-  0.01% )
         2,304,126      branches                  #  381.958 M/sec                    ( +-  0.00% )
            94,547      branch-misses             #    4.10% of all branches          ( +-  0.06% )

       0.006436610 seconds time elapsed                                          ( +-  0.88% )

$ perf stat -r 1000 perl5240o -e'BEGIN { @INC="/home/davem/perl5/a/perl-5.24.0o.out/lib/5.24.0" }  use strict; use warnings; use Exporter ()'
 
 Performance counter stats for 'perl5240o -eBEGIN { @INC="/home/davem/perl5/a/perl-5.24.0o.out/lib/5.24.0" }  use strict; use warnings; use Exporter ()' (1000 runs):

          5.811918      task-clock (msec)         #    0.937 CPUs utilized            ( +-  0.96% )
                 0      context-switches          #    0.004 K/sec                    ( +- 27.85% )
                 0      cpu-migrations            #    0.000 K/sec                    ( +-100.00% )
               249      page-faults               #    0.043 M/sec                    ( +-  0.02% )
        10,464,030      cycles                    #    1.800 GHz                      ( +-  0.16% )
         5,717,637      stalled-cycles-frontend   #   54.64% frontend cycles idle     ( +-  0.29% )
   <not supported>      stalled-cycles-backend   
        10,311,422      instructions              #    0.99  insns per cycle        
                                                  #    0.55  stalled cycles per insn  ( +-  0.01% )
         2,283,670      branches                  #  392.929 M/sec                    ( +-  0.01% )
            94,408      branch-misses             #    4.13% of all branches          ( +-  0.06% )

       0.006200003 seconds time elapsed                                          ( +-  0.94% )




-- 
A walk of a thousand miles begins with a single step...
then continues for another 1,999,999 or so.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About