1. 26 Feb, 2018 2 commits
  2. 24 Feb, 2018 10 commits
    • Jason Madden's avatar
      111521eb
    • Jason Madden's avatar
      Merge pull request #1120 from gevent/faster-stack · b3537301
      Jason Madden authored
      Speed up Greenlet creation on CPython
      b3537301
    • Jason Madden's avatar
      Changenotes. · 8d9ed09b
      Jason Madden authored
      8d9ed09b
    • Jason Madden's avatar
      Speed up Greenlet creation on CPython · 760a080c
      Jason Madden authored
      Two ways: store tuples instead of _frame objects and use direct access
      to two of the attributes of the CPython frame objects.
      
      Benchmarks:
      
      +------------------------+-----------------+------------------------------+
      | Benchmark              | spawn_27_master | spawn_27_tuple2              |
      +========================+=================+==============================+
      | eventlet sleep         | 9.12 us         | 8.77 us: 1.04x faster (-4%)  |
      +------------------------+-----------------+------------------------------+
      | gevent spawn           | 14.5 us         | 13.2 us: 1.10x faster (-9%)  |
      +------------------------+-----------------+------------------------------+
      | gevent sleep           | 1.63 us         | 1.86 us: 1.14x slower (+14%) |
      +------------------------+-----------------+------------------------------+
      | geventpool spawn       | 30.4 us         | 23.6 us: 1.29x faster (-22%) |
      +------------------------+-----------------+------------------------------+
      | geventpool sleep       | 4.30 us         | 4.55 us: 1.06x slower (+6%)  |
      +------------------------+-----------------+------------------------------+
      | geventpool join        | 1.70 us         | 1.83 us: 1.08x slower (+8%)  |
      +------------------------+-----------------+------------------------------+
      | gevent spawn kwarg     | 16.5 us         | 13.5 us: 1.22x faster (-18%) |
      +------------------------+-----------------+------------------------------+
      | geventpool spawn kwarg | 30.5 us         | 23.9 us: 1.27x faster (-22%) |
      +------------------------+-----------------+------------------------------+
      
      Not significant (7): eventlet spawn; geventraw spawn; geventraw sleep;
      none spawn; eventlet spawn kwarg; geventraw spawn kwarg; none spawn
      kwarg
      
      +------------------------+-----------------+------------------------------+
      | Benchmark              | spawn_36_master | spawn_36_tuple2              |
      +========================+=================+==============================+
      | gevent spawn           | 13.2 us         | 11.9 us: 1.12x faster (-10%) |
      +------------------------+-----------------+------------------------------+
      | gevent sleep           | 1.71 us         | 1.90 us: 1.11x slower (+11%) |
      +------------------------+-----------------+------------------------------+
      | geventpool spawn       | 19.9 us         | 15.9 us: 1.25x faster (-20%) |
      +------------------------+-----------------+------------------------------+
      | geventpool sleep       | 3.54 us         | 3.75 us: 1.06x slower (+6%)  |
      +------------------------+-----------------+------------------------------+
      | geventpool spawn kwarg | 20.3 us         | 15.9 us: 1.27x faster (-22%) |
      +------------------------+-----------------+------------------------------+
      | geventraw spawn kwarg  | 5.80 us         | 6.10 us: 1.05x slower (+5%)  |
      +------------------------+-----------------+------------------------------+
      
      Not significant (9): eventlet spawn; eventlet sleep; geventraw spawn;
      geventraw sleep; none spawn; geventpool join; eventlet spawn kwarg;
      gevent spawn kwarg; none spawn kwarg
      
      +------------------+-------------------+------------------------------+
      | Benchmark        | spawn_pypy_master | spawn_pypy_tuple2            |
      +==================+===================+==============================+
      | eventlet spawn   | 30.5 us           | 28.9 us: 1.05x faster (-5%)  |
      +------------------+-------------------+------------------------------+
      | eventlet sleep   | 3.39 us           | 3.19 us: 1.06x faster (-6%)  |
      +------------------+-------------------+------------------------------+
      | gevent spawn     | 9.89 us           | 17.2 us: 1.73x slower (+73%) |
      +------------------+-------------------+------------------------------+
      | gevent sleep     | 3.14 us           | 3.99 us: 1.27x slower (+27%) |
      +------------------+-------------------+------------------------------+
      | geventpool spawn | 12.3 us           | 20.1 us: 1.63x slower (+63%) |
      +------------------+-------------------+------------------------------+
      
      Not significant (1): geventpool sleep
      
      +------------------------+---------------+-------------------------------+
      | Benchmark              | spawn_36_13a1 | spawn_36_tuple2               |
      +========================+===============+===============================+
      | eventlet spawn         | 14.0 us       | 13.2 us: 1.06x faster (-6%)   |
      +------------------------+---------------+-------------------------------+
      | gevent spawn           | 4.25 us       | 11.9 us: 2.79x slower (+179%) |
      +------------------------+---------------+-------------------------------+
      | gevent sleep           | 2.78 us       | 1.90 us: 1.46x faster (-32%)  |
      +------------------------+---------------+-------------------------------+
      | geventpool spawn       | 10.4 us       | 15.9 us: 1.52x slower (+52%)  |
      +------------------------+---------------+-------------------------------+
      | geventpool sleep       | 5.52 us       | 3.75 us: 1.47x faster (-32%)  |
      +------------------------+---------------+-------------------------------+
      | geventraw spawn        | 2.56 us       | 5.09 us: 1.99x slower (+99%)  |
      +------------------------+---------------+-------------------------------+
      | geventraw sleep        | 738 ns        | 838 ns: 1.14x slower (+14%)   |
      +------------------------+---------------+-------------------------------+
      | geventpool join        | 3.94 us       | 1.75 us: 2.25x faster (-56%)  |
      +------------------------+---------------+-------------------------------+
      | gevent spawn kwarg     | 5.50 us       | 12.1 us: 2.19x slower (+119%) |
      +------------------------+---------------+-------------------------------+
      | geventpool spawn kwarg | 11.3 us       | 15.9 us: 1.41x slower (+41%)  |
      +------------------------+---------------+-------------------------------+
      | geventraw spawn kwarg  | 3.90 us       | 6.10 us: 1.56x slower (+56%)  |
      +------------------------+---------------+-------------------------------+
      
      Not significant (4): eventlet sleep; none spawn; eventlet spawn kwarg; none spawn kwarg
      
      The eventlet, sleep, join and raw tests serve as controls, so we can see
      that there's up to ~10% variance between most runs anyway.
      
      CPython 3.6 shows the least variance so those 10-20% improvement
      numbers are probably fairly close.
      
      PyPy sadly gets *slower* with this change for reasons that are utterly
      unclear.
      
      Compared to 1.3a1 (last benchmark) we're still up to 2-3x slower.
      
      Creation of a raw greenlet shows 2.66us on CPython 3.6.4 vs the 3.65us
      I reported in #755.
      760a080c
    • Jason Madden's avatar
    • Jason Madden's avatar
      Rework bench_spawn to be perf based for more reliable numbers · d705939b
      Jason Madden authored
      I get this on 3.6.4:
      
      .....................
      eventlet spawn: Mean +- std dev: 12.2 us +- 1.2 us
      .....................
      eventlet sleep: Mean +- std dev: 16.3 us +- 0.8 us
      .....................
      gevent spawn: Mean +- std dev: 13.1 us +- 1.1 us
      .....................
      gevent sleep: Mean +- std dev: 10.4 us +- 0.8 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (2.73 us) is 17% of the mean (16.1 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool spawn: Mean +- std dev: 16.1 us +- 2.7 us
      .....................
      geventpool sleep: Mean +- std dev: 11.2 us +- 0.5 us
      .....................
      geventraw spawn: Mean +- std dev: 4.95 us +- 0.42 us
      .....................
      geventraw sleep: Mean +- std dev: 7.34 us +- 0.28 us
      .....................
      none spawn: Mean +- std dev: 1.98 us +- 0.05 us
      .....................
      geventpool join: Mean +- std dev: 6.59 us +- 0.25 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (1.28 us) is 10% of the mean (12.7 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      eventlet spawn kwarg: Mean +- std dev: 12.7 us +- 1.3 us
      .....................
      gevent spawn kwarg: Mean +- std dev: 14.6 us +- 1.2 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (2.81 us) is 17% of the mean (17.0 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool spawn kwarg: Mean +- std dev: 17.0 us +- 2.8 us
      .....................
      geventraw spawn kwarg: Mean +- std dev: 6.11 us +- 0.45 us
      .....................
      none spawn kwarg: Mean +- std dev: 2.22 us +- 0.07 us
      
      And this on 2.7.14:
      
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (2.10 us) is 11% of the mean (18.4 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      eventlet spawn: Mean +- std dev: 18.4 us +- 2.1 us
      .....................
      eventlet sleep: Mean +- std dev: 23.1 us +- 0.8 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (4.39 us) is 25% of the mean (17.3 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      gevent spawn: Mean +- std dev: 17.3 us +- 4.4 us
      .....................
      gevent sleep: Mean +- std dev: 10.3 us +- 0.5 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (3.92 us) is 16% of the mean (24.7 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool spawn: Mean +- std dev: 24.7 us +- 3.9 us
      .....................
      geventpool sleep: Mean +- std dev: 13.5 us +- 0.9 us
      .....................
      geventraw spawn: Mean +- std dev: 6.91 us +- 0.49 us
      .....................
      geventraw sleep: Mean +- std dev: 8.95 us +- 0.30 us
      .....................
      none spawn: Mean +- std dev: 2.21 us +- 0.04 us
      .....................
      geventpool join: Mean +- std dev: 7.93 us +- 0.28 us
      .....................
      eventlet spawn kwarg: Mean +- std dev: 17.4 us +- 1.3 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (4.11 us) is 27% of the mean (15.1 us)
      * the maximum (24.2 us) is 60% greater than the mean (15.1 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      gevent spawn kwarg: Mean +- std dev: 15.1 us +- 4.1 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (4.74 us) is 18% of the mean (26.8 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool spawn kwarg: Mean +- std dev: 26.8 us +- 4.7 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (959 ns) is 12% of the mean (8.00 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventraw spawn kwarg: Mean +- std dev: 8.00 us +- 0.96 us
      .....................
      none spawn kwarg: Mean +- std dev: 2.48 us +- 0.06 us
      
      Partial PyPy results:
      
      .........
      WARNING: the benchmark result may be unstable
      * the standard deviation (5.77 us) is 18% of the mean (32.5 us)
      * the maximum (52.2 us) is 61% greater than the mean (32.5 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      eventlet spawn: Mean +- std dev: 32.5 us +- 5.8 us
      .........
      eventlet sleep: Mean +- std dev: 39.9 us +- 2.4 us
      .........
      WARNING: the benchmark result may be unstable
      * the standard deviation (8.90 us) is 43% of the mean (20.6 us)
      * the minimum (8.50 us) is 59% smaller than the mean (20.6 us)
      * the maximum (41.5 us) is 102% greater than the mean (20.6 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      gevent spawn: Mean +- std dev: 20.6 us +- 8.9 us
      .........
      gevent sleep: Mean +- std dev: 4.20 us +- 0.21 us
      .........
      WARNING: the benchmark result may be unstable
      * the standard deviation (8.52 us) is 50% of the mean (17.2 us)
      * the minimum (7.74 us) is 55% smaller than the mean (17.2 us)
      * the maximum (58.1 us) is 238% greater than the mean (17.2 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool spawn: Mean +- std dev: 17.2 us +- 8.5 us
      .........
      WARNING: the benchmark result may be unstable
      * the standard deviation (968 ns) is 18% of the mean (5.26 us)
      * the maximum (10.5 us) is 99% greater than the mean (5.26 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool sleep: Mean +- std dev: 5.26 us +- 0.97 us
      ..........
      WARNING: the benchmark result may be unstable
      * the standard deviation (1.45 us) is 52% of the mean (2.80 us)
      * the maximum (5.50 us) is 96% greater than the mean (2.80 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventraw spawn: Mean +- std dev: 2.80 us +- 1.45 us
      .........
      geventraw sleep: Mean +- std dev: 4.24 us +- 0.27 us
      .........
      none spawn: Mean +- std dev: 1.10 us +- 0.06 us
      d705939b
    • Jason Madden's avatar
    • Jason Madden's avatar
      Rework bench_spawn to be perf based for more reliable numbers · 3c3e7450
      Jason Madden authored
      I get this on 3.6.4:
      
      .....................
      eventlet spawn: Mean +- std dev: 12.2 us +- 1.2 us
      .....................
      eventlet sleep: Mean +- std dev: 16.3 us +- 0.8 us
      .....................
      gevent spawn: Mean +- std dev: 13.1 us +- 1.1 us
      .....................
      gevent sleep: Mean +- std dev: 10.4 us +- 0.8 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (2.73 us) is 17% of the mean (16.1 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool spawn: Mean +- std dev: 16.1 us +- 2.7 us
      .....................
      geventpool sleep: Mean +- std dev: 11.2 us +- 0.5 us
      .....................
      geventraw spawn: Mean +- std dev: 4.95 us +- 0.42 us
      .....................
      geventraw sleep: Mean +- std dev: 7.34 us +- 0.28 us
      .....................
      none spawn: Mean +- std dev: 1.98 us +- 0.05 us
      .....................
      geventpool join: Mean +- std dev: 6.59 us +- 0.25 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (1.28 us) is 10% of the mean (12.7 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      eventlet spawn kwarg: Mean +- std dev: 12.7 us +- 1.3 us
      .....................
      gevent spawn kwarg: Mean +- std dev: 14.6 us +- 1.2 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (2.81 us) is 17% of the mean (17.0 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool spawn kwarg: Mean +- std dev: 17.0 us +- 2.8 us
      .....................
      geventraw spawn kwarg: Mean +- std dev: 6.11 us +- 0.45 us
      .....................
      none spawn kwarg: Mean +- std dev: 2.22 us +- 0.07 us
      
      And this on 2.7.14:
      
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (2.10 us) is 11% of the mean (18.4 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      eventlet spawn: Mean +- std dev: 18.4 us +- 2.1 us
      .....................
      eventlet sleep: Mean +- std dev: 23.1 us +- 0.8 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (4.39 us) is 25% of the mean (17.3 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      gevent spawn: Mean +- std dev: 17.3 us +- 4.4 us
      .....................
      gevent sleep: Mean +- std dev: 10.3 us +- 0.5 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (3.92 us) is 16% of the mean (24.7 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool spawn: Mean +- std dev: 24.7 us +- 3.9 us
      .....................
      geventpool sleep: Mean +- std dev: 13.5 us +- 0.9 us
      .....................
      geventraw spawn: Mean +- std dev: 6.91 us +- 0.49 us
      .....................
      geventraw sleep: Mean +- std dev: 8.95 us +- 0.30 us
      .....................
      none spawn: Mean +- std dev: 2.21 us +- 0.04 us
      .....................
      geventpool join: Mean +- std dev: 7.93 us +- 0.28 us
      .....................
      eventlet spawn kwarg: Mean +- std dev: 17.4 us +- 1.3 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (4.11 us) is 27% of the mean (15.1 us)
      * the maximum (24.2 us) is 60% greater than the mean (15.1 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      gevent spawn kwarg: Mean +- std dev: 15.1 us +- 4.1 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (4.74 us) is 18% of the mean (26.8 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool spawn kwarg: Mean +- std dev: 26.8 us +- 4.7 us
      .....................
      WARNING: the benchmark result may be unstable
      * the standard deviation (959 ns) is 12% of the mean (8.00 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventraw spawn kwarg: Mean +- std dev: 8.00 us +- 0.96 us
      .....................
      none spawn kwarg: Mean +- std dev: 2.48 us +- 0.06 us
      
      Partial PyPy results:
      
      .........
      WARNING: the benchmark result may be unstable
      * the standard deviation (5.77 us) is 18% of the mean (32.5 us)
      * the maximum (52.2 us) is 61% greater than the mean (32.5 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      eventlet spawn: Mean +- std dev: 32.5 us +- 5.8 us
      .........
      eventlet sleep: Mean +- std dev: 39.9 us +- 2.4 us
      .........
      WARNING: the benchmark result may be unstable
      * the standard deviation (8.90 us) is 43% of the mean (20.6 us)
      * the minimum (8.50 us) is 59% smaller than the mean (20.6 us)
      * the maximum (41.5 us) is 102% greater than the mean (20.6 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      gevent spawn: Mean +- std dev: 20.6 us +- 8.9 us
      .........
      gevent sleep: Mean +- std dev: 4.20 us +- 0.21 us
      .........
      WARNING: the benchmark result may be unstable
      * the standard deviation (8.52 us) is 50% of the mean (17.2 us)
      * the minimum (7.74 us) is 55% smaller than the mean (17.2 us)
      * the maximum (58.1 us) is 238% greater than the mean (17.2 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool spawn: Mean +- std dev: 17.2 us +- 8.5 us
      .........
      WARNING: the benchmark result may be unstable
      * the standard deviation (968 ns) is 18% of the mean (5.26 us)
      * the maximum (10.5 us) is 99% greater than the mean (5.26 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventpool sleep: Mean +- std dev: 5.26 us +- 0.97 us
      ..........
      WARNING: the benchmark result may be unstable
      * the standard deviation (1.45 us) is 52% of the mean (2.80 us)
      * the maximum (5.50 us) is 96% greater than the mean (2.80 us)
      
      Try to rerun the benchmark with more runs, values and/or loops.
      Run 'python -m perf system tune' command to reduce the system jitter.
      Use perf stats, perf dump and perf hist to analyze results.
      Use --quiet option to hide these warnings.
      
      geventraw spawn: Mean +- std dev: 2.80 us +- 1.45 us
      .........
      geventraw sleep: Mean +- std dev: 4.24 us +- 0.27 us
      .........
      none spawn: Mean +- std dev: 1.10 us +- 0.06 us
      3c3e7450
    • Jason Madden's avatar
      Merge pull request #1119 from gevent/issue1118 · b84e1bd9
      Jason Madden authored
      Honor PURE_PYTHON at runtime
      b84e1bd9
    • Jason Madden's avatar
  3. 23 Feb, 2018 9 commits
    • Jason Madden's avatar
    • Jason Madden's avatar
      Use new cython on Windows too. · accd9cf6
      Jason Madden authored
      accd9cf6
    • Jason Madden's avatar
      Honor PURE_PYTHON at runtime. · 647918f7
      Jason Madden authored
      Fixes #1118.
      
      Also some speed improvements for semaphores.
      647918f7
    • Jason Madden's avatar
      Merge pull request #1117 from gevent/faster-locals · cfea657f
      Jason Madden authored
      Speed up gevent.local.local more, especially for subclasses (2-3x faster)
      cfea657f
    • Jason Madden's avatar
      Add link to pr #1117. [skip ci] · c6458a80
      Jason Madden authored
      c6458a80
    • Jason Madden's avatar
      Speed of gevent.local.local more, especially for subclasses (2-3x faster) · b1125a79
      Jason Madden authored
      Do this with some cython tricks and some caching of type attributes.
      Cython 0.28 compiles this code to be quite a bit faster than Cython
      0.27 does (the below uses 0.28), but it's still a win on both.
      
      The type caching could potentially be a compatibility issue, but in
      practice I suspect it won't be.
      
      Benchmarks on 3.6:
      
      +--------------------+------------------+-----------------------------+
      | Benchmark          | 3.6              | 3.6 This Branch             |
      +====================+==================+=============================+
      | getattr gevent     | 190 ns           | 158 ns: 1.20x faster (-17%) |
      +--------------------+------------------+-----------------------------+
      | setattr gevent     | 180 ns           | 165 ns: 1.09x faster (-8%)  |
      +--------------------+------------------+-----------------------------+
      | getattr gevent sub | 540 ns           | 175 ns: 3.09x faster (-68%) |
      +--------------------+------------------+-----------------------------+
      | setattr gevent sub | 528 ns           | 179 ns: 2.95x faster (-66%) |
      +--------------------+------------------+-----------------------------+
      | setattr native     | 80.8 ns          | 78.8 ns: 1.03x faster (-2%) |
      +--------------------+------------------+-----------------------------+
      
      Not significant (3): getattr native; getattr native sub; setattr native sub
      
      Benchmarks on 2.7:
      
      +--------------------+------------------+-----------------------------+
      | Benchmark          | local_27_master2 | local_27_tweak2             |
      +====================+==================+=============================+
      | getattr gevent     | 162 ns           | 158 ns: 1.03x faster (-3%)  |
      +--------------------+------------------+-----------------------------+
      | setattr gevent     | 173 ns           | 165 ns: 1.04x faster (-4%)  |
      +--------------------+------------------+-----------------------------+
      | getattr gevent sub | 471 ns           | 181 ns: 2.61x faster (-62%) |
      +--------------------+------------------+-----------------------------+
      | setattr gevent sub | 462 ns           | 190 ns: 2.44x faster (-59%) |
      +--------------------+------------------+-----------------------------+
      | getattr native     | 87.4 ns          | 89.7 ns: 1.03x slower (+3%) |
      +--------------------+------------------+-----------------------------+
      | setattr native     | 133 ns           | 110 ns: 1.20x faster (-17%) |
      +--------------------+------------------+-----------------------------+
      | getattr native sub | 101 ns           | 97.9 ns: 1.03x faster (-3%) |
      +--------------------+------------------+-----------------------------+
      | setattr native sub | 118 ns           | 111 ns: 1.06x faster (-6%)  |
      +--------------------+------------------+-----------------------------+
      
      PyPy unfortunately shows as a little slower, though I'm not sure I
      fully believe that:
      
      +--------------------+-------------------+-----------------------------+
      | Benchmark          | local_pypy_master | local_pypy_tweak2           |
      +====================+===================+=============================+
      | getattr gevent     | 135 ns            | 157 ns: 1.16x slower (+16%) |
      +--------------------+-------------------+-----------------------------+
      | setattr gevent     | 126 ns            | 162 ns: 1.28x slower (+28%) |
      +--------------------+-------------------+-----------------------------+
      | getattr gevent sub | 150 ns            | 175 ns: 1.17x slower (+17%) |
      +--------------------+-------------------+-----------------------------+
      | setattr gevent sub | 153 ns            | 183 ns: 1.20x slower (+20%) |
      +--------------------+-------------------+-----------------------------+
      | getattr native     | 0.18 ns           | 0.19 ns: 1.05x slower (+5%) |
      +--------------------+-------------------+-----------------------------+
      | setattr native     | 0.18 ns           | 0.20 ns: 1.06x slower (+6%) |
      +--------------------+-------------------+-----------------------------+
      | getattr native sub | 0.18 ns           | 0.19 ns: 1.05x slower (+5%) |
      +--------------------+-------------------+-----------------------------+
      | setattr native sub | 0.19 ns           | 0.18 ns: 1.06x faster (-6%) |
      +--------------------+-------------------+-----------------------------+
      b1125a79
    • Jason Madden's avatar
      Add a script for benchmarking gevent.local · d9602bf8
      Jason Madden authored
      [skip ci]
      Current numbers:
      
      local_36_master
      ===============
      
      getattr gevent: Mean +- std dev: 216 ns +- 6 ns
      setattr gevent: Mean +- std dev: 215 ns +- 6 ns
      getattr gevent sub: Mean +- std dev: 600 ns +- 19 ns
      setattr gevent sub: Mean +- std dev: 591 ns +- 38 ns
      getattr native: Mean +- std dev: 56.9 ns +- 4.1 ns
      setattr native: Mean +- std dev: 84.3 ns +- 4.9 ns
      getattr native sub: Mean +- std dev: 65.6 ns +- 5.3 ns
      setattr native sub: Mean +- std dev: 76.2 ns +- 4.6 ns
      
      local_27_master
      ===============
      
      getattr gevent: Mean +- std dev: 177 ns +- 7 ns
      setattr gevent: Mean +- std dev: 192 ns +- 6 ns
      getattr gevent sub: Mean +- std dev: 501 ns +- 10 ns
      setattr gevent sub: Mean +- std dev: 536 ns +- 25 ns
      getattr native: Mean +- std dev: 93.8 ns +- 3.6 ns
      setattr native: Mean +- std dev: 118 ns +- 6 ns
      getattr native sub: Mean +- std dev: 102 ns +- 4 ns
      setattr native sub: Mean +- std dev: 118 ns +- 8 ns
      
      local_pypy_master
      =================
      
      getattr gevent: Mean +- std dev: 135 ns +- 6 ns
      setattr gevent: Mean +- std dev: 126 ns +- 4 ns
      getattr gevent sub: Mean +- std dev: 150 ns +- 4 ns
      setattr gevent sub: Mean +- std dev: 153 ns +- 7 ns
      getattr native: Mean +- std dev: 0.18 ns +- 0.00 ns
      setattr native: Mean +- std dev: 0.18 ns +- 0.01 ns
      getattr native sub: Mean +- std dev: 0.18 ns +- 0.01 ns
      setattr native sub: Mean +- std dev: 0.19 ns +- 0.01 ns
      d9602bf8
    • Jason Madden's avatar
      Merge pull request #1116 from gevent/issue755 · 43e776b6
      Jason Madden authored
      Add Greenlet.minimal_ident, a small, sequential, reusable counter for greenlets
      43e776b6
    • Jason Madden's avatar
      Tweak changenote [skip ci] · 5af60cc7
      Jason Madden authored
      5af60cc7
  4. 22 Feb, 2018 10 commits
  5. 21 Feb, 2018 2 commits
    • Jason Madden's avatar
      Add spawn_tree_locals, spawning_greenlet and spawning_stack to Greenlet · 15fc1ecc
      Jason Madden authored
      Based on #755.
      
      A comment in the code goes into detail about the timing. Here it is
      again:
      
       Timings taken Feb 21 2018 prior to integration of #755
       python -m perf timeit -s 'import gevent' 'gevent.Greenlet()'
       3.6.4       : Mean +- std dev: 1.08 us +- 0.05 us
       2.7.14      : Mean +- std dev: 1.44 us +- 0.06 us
       PyPy2 5.10.0: Mean +- std dev: 2.14 ns +- 0.08 ns
      
       After the integration of spawning_stack, spawning_greenlet,
       and spawn_tree_locals on that same date:
       3.6.4       : Mean +- std dev: 8.92 us +- 0.36 us ->  8.2x
       2.7.14      : Mean +- std dev: 14.8 us +- 0.5 us  -> 10.2x
       PyPy2 5.10.0: Mean +- std dev: 3.24 us +- 0.17 us ->  1.5x
      
      Selected bench_spawn output on 3.6.4 before:
      
      //gevent36/bin/python src/greentest/bench_spawn.py eventlet --ignore-import-errors
      using eventlet from //gevent36/lib/python3.6/site-packages/eventlet/__init__.py
      spawning: 11.93 microseconds per greenlet
      sleep(0): 23.49 microseconds per greenlet
      
      //gevent36/bin/python src/greentest/bench_spawn.py gevent --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 3.39 microseconds per greenlet
      sleep(0): 17.59 microseconds per greenlet
      
      //gevent36/bin/python src/greentest/bench_spawn.py geventpool --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 8.71 microseconds per greenlet
      
      //gevent36/bin/python src/greentest/bench_spawn.py geventraw --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 2.09 microseconds per greenlet
      
      //gevent36/bin/python src/greentest/bench_spawn.py none --ignore-import-errors
          noop: 0.33 microseconds per greenlet
      
      And after:
      
      //gevent36/bin/python bench_spawn.py gevent --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 12.99 microseconds per greenlet -> 3.8x
      
      //gevent36/bin/python bench_spawn.py geventpool --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 19.49 microseconds per greenlet -> 2.2x
      
      //gevent36/bin/python bench_spawn.py geventraw --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 4.57 microseconds per greenlet -> 2.2x
      
      We're approximately the speed of eventlet now.
      
      Refs #755
      15fc1ecc
    • Jason Madden's avatar
      Update bench_spawn · 54ffea34
      Jason Madden authored
      Current numbers on my workstation:
      
      CPython 3.6.4
      
      //gevent36/bin/python bench_spawn.py eventlet --ignore-import-errors
      using eventlet from //python3.6/site-packages/eventlet/__init__.py
      spawning: 11.93 microseconds per greenlet
      sleep(0): 23.49 microseconds per greenlet
      
      //gevent36/bin/python bench_spawn.py gevent --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 3.39 microseconds per greenlet
      sleep(0): 17.59 microseconds per greenlet
      
      //gevent36/bin/python bench_spawn.py geventpool --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 8.71 microseconds per greenlet
      sleep(0): 16.99 microseconds per greenlet
       joining: 7.34 microseconds per greenlet
      
      //gevent36/bin/python bench_spawn.py geventraw --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 2.09 microseconds per greenlet
      sleep(0): 13.57 microseconds per greenlet
      
      //gevent36/bin/python bench_spawn.py none --ignore-import-errors
          noop: 0.33 microseconds per greenlet
      
      //gevent36/bin/python bench_spawn.py --with-kwargs eventlet --ignore-import-errors
      using eventlet from //python3.6/site-packages/eventlet/__init__.py
      spawning: 12.06 microseconds per greenlet
      sleep(0): 24.25 microseconds per greenlet
      
      //gevent36/bin/python bench_spawn.py --with-kwargs gevent --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 4.62 microseconds per greenlet
      sleep(0): 22.18 microseconds per greenlet
      
      //gevent36/bin/python bench_spawn.py --with-kwargs geventpool --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 10.25 microseconds per greenlet
      sleep(0): 18.89 microseconds per greenlet
       joining: 7.14 microseconds per greenlet
      
      //gevent36/bin/python bench_spawn.py --with-kwargs geventraw --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 3.27 microseconds per greenlet
      sleep(0): 15.03 microseconds per greenlet
      
      //gevent36/bin/python bench_spawn.py --with-kwargs none --ignore-import-errors
          noop: 0.50 microseconds per greenlet
      
      CPython 2.7.14
      
      //gevent27/bin/python bench_spawn.py eventlet --ignore-import-errors
      using eventlet from //python2.7/site-packages/eventlet/__init__.pyc
      spawning: 17.84 microseconds per greenlet
      sleep(0): 31.42 microseconds per greenlet
      
      //gevent27/bin/python bench_spawn.py gevent --ignore-import-errors
      using gevent from //src/gevent/__init__.pyc
      spawning: 4.95 microseconds per greenlet
      sleep(0): 21.40 microseconds per greenlet
      
      //gevent27/bin/python bench_spawn.py geventpool --ignore-import-errors
      using gevent from //src/gevent/__init__.pyc
      spawning: 12.44 microseconds per greenlet
      sleep(0): 22.90 microseconds per greenlet
       joining: 10.68 microseconds per greenlet
      
      //gevent27/bin/python bench_spawn.py geventraw --ignore-import-errors
      using gevent from //src/gevent/__init__.pyc
      spawning: 2.33 microseconds per greenlet
      sleep(0): 15.11 microseconds per greenlet
      
      //gevent27/bin/python bench_spawn.py none --ignore-import-errors
          noop: 0.58 microseconds per greenlet
      
      //gevent27/bin/python bench_spawn.py --with-kwargs eventlet --ignore-import-errors
      using eventlet from //python2.7/site-packages/eventlet/__init__.pyc
      spawning: 19.38 microseconds per greenlet
      sleep(0): 31.62 microseconds per greenlet
      
      //gevent27/bin/python bench_spawn.py --with-kwargs gevent --ignore-import-errors
      using gevent from //src/gevent/__init__.pyc
      spawning: 6.59 microseconds per greenlet
      sleep(0): 23.12 microseconds per greenlet
      
      //gevent27/bin/python bench_spawn.py --with-kwargs geventpool --ignore-import-errors
      using gevent from //src/gevent/__init__.pyc
      spawning: 13.78 microseconds per greenlet
      sleep(0): 21.65 microseconds per greenlet
       joining: 10.86 microseconds per greenlet
      
      //gevent27/bin/python bench_spawn.py --with-kwargs geventraw --ignore-import-errors
      using gevent from //src/gevent/__init__.pyc
      spawning: 3.59 microseconds per greenlet
      sleep(0): 16.14 microseconds per greenlet
      
      //gevent27/bin/python bench_spawn.py --with-kwargs none --ignore-import-errors
          noop: 0.65 microseconds per greenlet
      
      PyPy2 5.10.0
      
      //geventpypy/bin/python bench_spawn.py eventlet --ignore-import-errors
      using eventlet from //geventpypy/site-packages/eventlet/__init__.pyc
      spawning: 29.91 microseconds per greenlet
      sleep(0): 84.24 microseconds per greenlet
      
      //geventpypy/bin/python bench_spawn.py gevent --ignore-import-errors
      using gevent from //src/gevent/__init__.py
      spawning: 0.73 microseconds per greenlet
      sleep(0): 33.02 microseconds per greenlet
      
      //geventpypy/bin/python bench_spawn.py geventpool --ignore-import-errors
      using gevent from //src/gevent/__init__.pyc
      spawning: 2.49 microseconds per greenlet
      sleep(0): 38.56 microseconds per greenlet
       joining: 13.08 microseconds per greenlet
      
      //geventpypy/bin/python bench_spawn.py geventraw --ignore-import-errors
      using gevent from //src/gevent/__init__.pyc
      spawning: 0.52 microseconds per greenlet
      sleep(0): 29.63 microseconds per greenlet
      
      //geventpypy/bin/python bench_spawn.py none --ignore-import-errors
          noop: 0.02 microseconds per greenlet
      
      //geventpypy/bin/python bench_spawn.py --with-kwargs eventlet --ignore-import-errors
      using eventlet from //geventpypy/site-packages/eventlet/__init__.pyc
      spawning: 30.36 microseconds per greenlet
      sleep(0): 83.00 microseconds per greenlet
      
      //geventpypy/bin/python bench_spawn.py --with-kwargs gevent --ignore-import-errors
      using gevent from //src/gevent/__init__.pyc
      spawning: 1.56 microseconds per greenlet
      sleep(0): 34.80 microseconds per greenlet
      
      //geventpypy/bin/python bench_spawn.py --with-kwargs geventpool --ignore-import-errors
      using gevent from //src/gevent/__init__.pyc
      spawning: 3.48 microseconds per greenlet
      sleep(0): 39.43 microseconds per greenlet
       joining: 16.21 microseconds per greenlet
      
      //geventpypy/bin/python bench_spawn.py --with-kwargs geventraw --ignore-import-errors
      using gevent from //src/gevent/__init__.pyc
      spawning: 1.51 microseconds per greenlet
      sleep(0): 52.19 microseconds per greenlet
      
      //geventpypy/bin/python bench_spawn.py --with-kwargs none --ignore-import-errors
          noop: 0.13 microseconds per greenlet
      
      [skip ci]
      54ffea34
  6. 20 Feb, 2018 7 commits