Opened 4 years ago

Closed 4 years ago

#9271 closed task (fixed)

Avoid unnecessary clock_gettime() syscalls in GC stats.

Reported by: brbr Owned by: brbr
Priority: normal Milestone:
Component: Runtime System Version: 7.8.2
Keywords: Cc: simonmar
Operating System: POSIX Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Avoid unnecessary clock_gettime() syscalls in GC stats.

https://phabricator.haskell.org/D39

Avoiding the unnecessary call appears to save ~12ms of work per second. That's 17 minutes a day!

Unsure if the frequency of this particular GC stats function for this fib program is the same for all Haskell programs..

Simple benchmark program with before/after strace -c output:

fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)

main = putStrLn $ show (fib 35)

Before:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 52.73    0.110738           5     20318           clock_gettime
 44.16    0.092733           5     20319           rt_sigprocmask
  2.14    0.004503           8       532           rt_sigreturn
  0.24    0.000514          21        25           mmap
...
  0.00    0.000008           8         1           set_robust_list
  0.00    0.000007           7         1           select
------ ----------- ----------- --------- --------- ----------------
100.00    0.210001                 41285        10 total

After:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 59.24    0.094986           5     20319           rt_sigprocmask
 36.85    0.059094           6     10161           clock_gettime
  2.78    0.004463           8       527           rt_sigreturn
  0.26    0.000417          17        25           mmap
...
  0.00    0.000007           7         1           set_robust_list
  0.00    0.000006           6         1           select
------ ----------- ----------- --------- --------- ----------------
100.00    0.160354                 31123        10 total

nofib results:

--------------------------------------------------------------------------------
        Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
           anna          -0.0%      0.0%      0.10      0.10      0.0%
           ansi          -0.0%      0.0%      0.00      0.00      0.0%
           atom          -0.0%      0.0%     +0.4%      0.0%      0.0%
         awards          -0.0%      0.0%      0.00      0.00      0.0%
         banner          -0.0%      0.0%      0.00      0.00      0.0%
     bernouilli          -0.0%      0.0%      0.15      0.15      0.0%
   binary-trees          -0.0%      0.0%     +0.3%     +0.3%      0.0%
          boyer          -0.0%      0.0%      0.04      0.04      0.0%
         boyer2          -0.0%      0.0%      0.00      0.00      0.0%
           bspt          -0.0%      0.0%      0.01      0.01      0.0%
      cacheprof          -0.0%     -0.0%     +0.5%     +0.5%     +1.8%
       calendar          -0.0%      0.0%      0.00      0.00      0.0%
       cichelli          -0.0%      0.0%      0.08      0.08      0.0%
        circsim          -0.0%      0.0%     -0.6%     -0.2%      0.0%
       clausify          -0.0%      0.0%      0.03      0.03      0.0%
  comp_lab_zift          -0.0%      0.0%      0.18      0.18      0.0%
       compress          -0.0%      0.0%      0.15      0.15      0.0%
      compress2          -0.0%      0.0%      0.16      0.16      0.0%
    constraints          -0.0%      0.0%     -0.4%     -0.2%      0.0%
   cryptarithm1          -0.0%      0.0%     +0.4%     +0.7%      0.0%
   cryptarithm2          -0.0%      0.0%      0.01      0.01      0.0%
            cse          -0.0%      0.0%      0.00      0.00      0.0%
          eliza          -0.0%      0.0%      0.00      0.00      0.0%
          event          -0.0%      0.0%      0.14      0.14      0.0%
         exp3_8          -0.0%      0.0%      0.19      0.19      0.0%
         expert          -0.0%      0.0%      0.00      0.00      0.0%
 fannkuch-redux          -0.0%     +0.0%     +0.3%     +0.1%      0.0%
          fasta          -0.0%      0.0%     +0.8%     +1.2%      0.0%
            fem          -0.0%      0.0%      0.02      0.02      0.0%
            fft          -0.0%      0.0%      0.04      0.04      0.0%
           fft2          -0.0%      0.0%      0.05      0.05      0.0%
       fibheaps          -0.0%      0.0%      0.02      0.02      0.0%
           fish          -0.0%      0.0%      0.01      0.01      0.0%
          fluid          -0.0%      0.0%      0.01      0.01      0.0%
         fulsom          -0.0%      0.0%     -2.3%     -2.3%      0.0%
         gamteb          -0.0%      0.0%      0.03      0.03      0.0%
            gcd          -0.0%      0.0%      0.03      0.03      0.0%
    gen_regexps          -0.0%      0.0%      0.00      0.00      0.0%
         genfft          -0.0%      0.0%      0.04      0.04      0.0%
             gg          -0.0%      0.0%      0.02      0.02      0.0%
           grep          -0.0%      0.0%      0.00      0.00      0.0%
         hidden          -0.0%      0.0%     +1.0%     +1.5%      0.0%
            hpg          -0.0%      0.0%      0.17      0.17      0.0%
            ida          -0.0%      0.0%      0.07      0.07      0.0%
          infer          -0.0%      0.0%      0.06      0.06      0.0%
        integer          -0.0%      0.0%     -5.0%     -4.9%      0.0%
      integrate          -0.0%      0.0%      0.13      0.13      0.0%
   k-nucleotide          -0.0%      0.0%     -0.4%     -0.4%      0.0%
          kahan          -0.0%      0.0%     -0.7%      0.0%      0.0%
        knights          -0.0%      0.0%      0.01      0.01      0.0%
           lcss          -0.0%      0.0%     +1.3%     +0.9%      0.0%
           life          -0.0%      0.0%     -2.4%     -2.4%      0.0%
           lift          -0.0%      0.0%      0.00      0.00      0.0%
      listcompr          -0.0%      0.0%      0.07      0.07      0.0%
       listcopy          -0.0%      0.0%      0.09      0.09      0.0%
       maillist          -0.0%     +0.0%      0.06      0.06     -1.1%
         mandel          -0.0%      0.0%      0.06      0.06      0.0%
        mandel2          -0.0%      0.0%      0.00      0.00      0.0%
        minimax          -0.0%      0.0%      0.00      0.00      0.0%
        mkhprog          -0.0%      0.0%      0.00      0.00      0.0%
     multiplier          -0.0%      0.0%      0.12      0.12      0.0%
         n-body          -0.0%      0.0%     +1.4%     +1.5%      0.0%
       nucleic2          -0.0%      0.0%      0.05      0.05      0.0%
           para          -0.0%      0.0%      0.0%      0.0%      0.0%
      paraffins          -0.0%      0.0%      0.12      0.12      0.0%
         parser          -0.0%      0.0%      0.03      0.03      0.0%
        parstof          -0.0%      0.0%      0.00      0.00      0.0%
            pic          -0.0%      0.0%      0.00      0.00      0.0%
       pidigits          -0.0%      0.0%     -0.4%     -0.4%      0.0%
          power          -0.0%      0.0%      0.0%     +0.4%     +3.6%
         pretty          -0.0%      0.0%      0.00      0.00      0.0%
         primes          -0.0%      0.0%      0.07      0.07      0.0%
      primetest          -0.0%      0.0%      0.07      0.07      0.0%
         prolog          -0.0%      0.0%      0.00      0.00      0.0%
         puzzle          -0.0%      0.0%      0.14      0.14      0.0%
         queens          -0.0%      0.0%      0.01      0.01      0.0%
        reptile          -0.0%      0.0%      0.02      0.02      0.0%
reverse-complem          -0.0%      0.0%      0.12      0.12      0.0%
        rewrite          -0.0%      0.0%      0.01      0.01      0.0%
           rfib          -0.0%      0.0%      0.02      0.02      0.0%
            rsa          -0.0%      0.0%      0.02      0.02      0.0%
            scc          -0.0%      0.0%      0.00      0.00      0.0%
          sched          -0.0%      0.0%      0.02      0.02      0.0%
            scs          -0.0%      0.0%     -0.8%     -0.8%      0.0%
         simple          -0.0%      0.0%      0.0%      0.0%      0.0%
          solid          -0.0%      0.0%      0.13      0.13      0.0%
        sorting          -0.0%      0.0%      0.00      0.00      0.0%
  spectral-norm          -0.0%      0.0%      0.0%      0.0%      0.0%
         sphere          -0.0%      0.0%      0.04      0.04      0.0%
         symalg          -0.0%      0.0%      0.01      0.01      0.0%
            tak          -0.0%      0.0%      0.01      0.01      0.0%
      transform          -0.0%      0.0%      0.0%      0.0%      0.0%
       treejoin          -0.0%      0.0%      0.16      0.16      0.0%
      typecheck          -0.0%      0.0%      0.20      0.20      0.0%
        veritas          -0.0%      0.0%      0.00      0.00      0.0%
           wang          -0.0%      0.0%      0.13      0.13      0.0%
      wave4main          -0.0%      0.0%      0.0%      0.0%      0.0%
   wheel-sieve1          -0.0%      0.0%      0.0%      0.0%      0.0%
   wheel-sieve2          -0.0%      0.0%     -1.6%     -2.4%      0.0%
           x2n1          -0.0%      0.0%      0.00      0.00      0.0%
--------------------------------------------------------------------------------
            Min          -0.0%     -0.0%     -5.0%     -4.9%     -1.1%
            Max          -0.0%     +0.0%     +1.4%     +1.5%     +3.6%
 Geometric Mean          -0.0%     -0.0%     -0.3%     -0.3%     +0.0%

Change History (3)

comment:1 Changed 4 years ago by rwbarton

Wow, nice catch!

comment:2 Changed 4 years ago by brbr

Owner: changed from simonmar to brbr

comment:3 Changed 4 years ago by brbr

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.