1. 06 Mar, 2018 8 commits
  2. 04 Mar, 2018 3 commits
  3. 03 Mar, 2018 9 commits
  4. 02 Mar, 2018 6 commits
  5. 28 Feb, 2018 2 commits
  6. 27 Feb, 2018 4 commits
    • Jason Madden's avatar
      Merge pull request #1123 from gevent/locals-debug · d56054cf
      Jason Madden authored
      Add a GreenletTree for more organized, clearer output of greenlets
      d56054cf
    • Jason Madden's avatar
      Add a GreenletTree for more organized, clearer output of greenlets · 5d4bdad6
      Jason Madden authored
      It organizes things by the spawning greenlet, if possible.
      
      Example output::
      
      ```
      <greenlet.greenlet object at 0x10753a9b0>
       :    Running:
       :      File "/tmp/t.py", line 38, in <module>
       :        print("\n".join(format_run_info()))
       :      File "//src/gevent/util.py", line 99, in format_run_info
       :        _format_greenlet_info(lines)
       :      File "//src/gevent/util.py", line 132, in _format_greenlet_info
       :        lines.extend(tree.format_lines(details=True))
       :      File "//src/gevent/util.py", line 265, in format_lines
       :        for l in self._render(tree)]
       :      File "/-main/src/gevent/util.py", line 310, in _render
       :        self.__render_tb(tree, 'Running:', self.greenlet.gr_frame)
       :      File "//src/gevent/util.py", line 281, in __render_tb
       :        tb = ''.join(traceback.format_stack(frame))
       :    Greenlet Locals:
       :      Local <type 'gevent._local.local'> at 0x10759cec0
       :        {'foo': 42}
       +--- <Greenlet "Greenlet-0" at 0x107405cb0: _run>; finished with value <Greenlet "Greenlet-4" at 0x10
       :          Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
       :          Spawned at:
       :            File "/tmp/t.py", line 1, in <module>
       :              from gevent.util import GreenletTree
       |    +--- <Greenlet "Greenlet-4" at 0x10780b260: _run>; finished
       :                Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
       :                Spawned at:
       :                  File "/tmp/t.py", line 1, in <module>
       :                    from gevent.util import GreenletTree
       :                  File "/tmp/t.py", line 12, in t2
       :                    def t2():
       +--- <Hub at 0x10753a550 select default pending=0 ref=0>
       :          Parent: <greenlet.greenlet object at 0x10753a9b0>
       :          Running:
       :            File "/Users/jmadden/Projects/GithubSources/gevent-main/src/gevent/hub.py", line 673, in run
       :              loop.run()
       +--- <Greenlet "Greenlet-1" at 0x10780b368: _run>; finished with value <Greenlet "Greenlet-5" at 0x10
       :          Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
       :          Spawned at:
       :            File "/tmp/t.py", line 1, in <module>
       :              from gevent.util import GreenletTree
       |    +--- <Greenlet "Greenlet-5" at 0x10780b578: _run>; finished
       :                Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
       :                Spawned at:
       :                  File "/tmp/t.py", line 1, in <module>
       :                    from gevent.util import GreenletTree
       :                  File "/tmp/t.py", line 12, in t2
       :                    def t2():
       +--- <Greenlet "Greenlet-2" at 0x10780b470: _run>; finished with value <Greenlet "Greenlet-6" at 0x10
       :          Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
       :          Spawned at:
       :            File "/tmp/t.py", line 1, in <module>
       :              from gevent.util import GreenletTree
       :          Spawn Tree Locals
       :          {'stl': 'STL'}
       |    +--- <Greenlet "Greenlet-6" at 0x10780b680: _run>; finished with value <Greenlet "Greenlet-7" at 0x10
       :                Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
       :                Spawned at:
       :                  File "/tmp/t.py", line 1, in <module>
       :                    from gevent.util import GreenletTree
       :                  File "/tmp/t.py", line 21, in t3
       :                    def t3():
       |         +--- <Greenlet "Greenlet-7" at 0x10780b788: _run>; finished
       :                      Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
       :                      Spawned at:
       :                        File "/tmp/t.py", line 1, in <module>
       :                          from gevent.util import GreenletTree
       :                        File "/tmp/t.py", line 21, in t3
       :                          def t3():
       :                        File "/tmp/t.py", line 12, in t2
       :                          def t2():
       +--- <Greenlet "Greenlet-3" at 0x10780b890: _run>; finished with value [<gevent.util.GreenletTree obj
                  Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
                  Spawned at:
                    File "/tmp/t.py", line 1, in <module>
                      from gevent.util import GreenletTree
      ```
      5d4bdad6
    • Jason Madden's avatar
    • Jason Madden's avatar
  7. 26 Feb, 2018 4 commits
  8. 24 Feb, 2018 4 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