1. 31
  1.  

  2. 26

    What do you do when libc is your bottleneck?

    Hit the bar, job’s done.

    1. 17

      You switch to a better libc:

       Performance counter stats for './empty-gcc' (10000 runs):
      
                0.322430      task-clock (msec)         #    0.503 CPUs utilized            ( +-  0.28% )
                       0      context-switches          #    0.048 K/sec                    ( +- 10.25% )
                       0      cpu-migrations            #    0.117 K/sec                    ( +-  5.13% )
                      41      page-faults               #    0.128 M/sec                    ( +-  0.03% )
                 598,958      cycles                    #    1.858 GHz                      ( +-  0.19% )
                 383,746      stalled-cycles-frontend   #   64.07% frontend cycles idle     ( +-  0.31% )
                 276,548      stalled-cycles-backend    #   46.17% backend  cycles idle     ( +-  0.33% )
                 490,145      instructions              #    0.82  insns per cycle        
                                                        #    0.78  stalled cycles per insn  ( +-  0.02% )
                  91,731      branches                  #  284.500 M/sec                    ( +-  0.02% )
                   2,787      branch-misses             #    3.04% of all branches          ( +-  0.08% )
      
             0.000640934 seconds time elapsed                                          ( +-  0.32% )
      
       Performance counter stats for './empty-musl' (10000 runs):
      
                0.130167      task-clock (msec)         #    0.298 CPUs utilized            ( +-  0.29% )
                       0      context-switches          #    0.030 K/sec                    ( +- 15.98% )
                       0      cpu-migrations            #    0.108 K/sec                    ( +-  8.36% )
                      13      page-faults               #    0.102 M/sec                    ( +-  0.05% )
                 236,145      cycles                    #    1.814 GHz                      ( +-  0.18% )
                 148,424      stalled-cycles-frontend   #   62.85% frontend cycles idle     ( +-  0.30% )
                 106,497      stalled-cycles-backend    #   45.10% backend  cycles idle     ( +-  0.32% )
                 192,166      instructions              #    0.81  insns per cycle        
                                                        #    0.77  stalled cycles per insn  ( +-  0.03% )
                  35,685      branches                  #  274.146 M/sec                    ( +-  0.03% )
                   1,154      branch-misses             #    3.23% of all branches          ( +-  0.11% )
      
             0.000436624 seconds time elapsed                                          ( +-  0.40% )
      
       Performance counter stats for './empty-musl-static' (10000 runs):
      
                0.059110      task-clock (msec)         #    0.159 CPUs utilized            ( +-  0.33% )
                       0      context-switches          #    0.020 K/sec                    ( +- 28.85% )
                       0      cpu-migrations            #    0.078 K/sec                    ( +- 14.71% )
                       3      page-faults               #    0.051 M/sec                    ( +-  0.18% )
                  92,899      cycles                    #    1.572 GHz                      ( +-  0.13% )
                  63,191      stalled-cycles-frontend   #   68.02% frontend cycles idle     ( +-  0.18% )
                  47,468      stalled-cycles-backend    #   51.10% backend  cycles idle     ( +-  0.20% )
                  65,718      instructions              #    0.71  insns per cycle        
                                                        #    0.96  stalled cycles per insn  ( +-  0.05% )
                   9,884      branches                  #  167.212 M/sec                    ( +-  0.05% )
                     383      branch-misses             #    3.88% of all branches          ( +-  0.25% )
      
             0.000371957 seconds time elapsed                                          ( +-  0.37% )
      
      1. 10

        As a fellow victim of level0 nerdsniping, I am amazed. Great writeup (-:

        Fun fact: At Stripe, we beta-tested this level (and the submission infrastructure) a few weeks before the CTF launched, and it seems every single developer lost an entire week of productivity. Everyone suddenly got extremely serious about spellchecking. People were working furiously. Traps were set, insurance policy solutions were kept back strategically to catapult contestants up the ranks when they got beaten, it was pandemonium. I don’t think anyone wrote their own libc though.