New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile gevent.queue and gevent.hub.waiter with Cython #1155

Merged
merged 4 commits into from Mar 26, 2018

Conversation

Projects
None yet
2 participants
@jamadden
Member

jamadden commented Mar 25, 2018

This gives massive performance benefits to queues:

Benchmark 27_queue_master 27_queue_cython2
bench_unbounded_queue_noblock 2.09 us 622 ns: 3.37x faster (-70%)
bench_bounded_queue_noblock 2.55 us 634 ns: 4.02x faster (-75%)
bench_bounded_queue_block 36.1 us 7.29 us: 4.95x faster (-80%)
bench_channel 15.4 us 6.40 us: 2.40x faster (-58%)
bench_bounded_queue_block_hub 13.6 us 3.89 us: 3.48x faster (-71%)
bench_channel_hub 7.55 us 3.38 us: 2.24x faster (-55%)
bench_unbounded_priority_queue_noblock 5.02 us 3.18 us: 1.58x faster (-37%)
bench_bounded_priority_queue_noblock 5.48 us 3.22 us: 1.70x faster (-41%)

In a "real" use caes (pool.imap) it shows up as a 10-20% improvement:

Benchmark 36_pool_event5 36_pool_ubq_cython
imap_unordered_seq 553 us 461 us: 1.20x faster (-17%)
imap_unordered_par 301 us 265 us: 1.14x faster (-12%)
imap_seq 587 us 497 us: 1.18x faster (-15%)
imap_par 326 us 275 us: 1.19x faster (-16%)
spawn 310 us 284 us: 1.09x faster (-8%)

Not significant (3): map_seq; map_par; apply

Compile gevent.queue and gevent.hub.waiter with Cython
This gives massive performance benefits to queues:

| Benchmark                              | 27_queue_master | 27_queue_cython2             |
|----------------------------------------|-----------------|------------------------------|
| bench_unbounded_queue_noblock          | 2.09 us         | 622 ns: 3.37x faster (-70%)  |
| bench_bounded_queue_noblock            | 2.55 us         | 634 ns: 4.02x faster (-75%)  |
| bench_bounded_queue_block              | 36.1 us         | 7.29 us: 4.95x faster (-80%) |
| bench_channel                          | 15.4 us         | 6.40 us: 2.40x faster (-58%) |
| bench_bounded_queue_block_hub          | 13.6 us         | 3.89 us: 3.48x faster (-71%) |
| bench_channel_hub                      | 7.55 us         | 3.38 us: 2.24x faster (-55%) |
| bench_unbounded_priority_queue_noblock | 5.02 us         | 3.18 us: 1.58x faster (-37%) |
| bench_bounded_priority_queue_noblock   | 5.48 us         | 3.22 us: 1.70x faster (-41%) |

In a "real" use caes (pool.imap) it shows up as a 10-20% improvement:

| Benchmark          | 36_pool_event5 | 36_pool_ubq_cython          |
|--------------------|----------------|-----------------------------|
| imap_unordered_seq | 553 us         | 461 us: 1.20x faster (-17%) |
| imap_unordered_par | 301 us         | 265 us: 1.14x faster (-12%) |
| imap_seq           | 587 us         | 497 us: 1.18x faster (-15%) |
| imap_par           | 326 us         | 275 us: 1.19x faster (-16%) |
| spawn              | 310 us         | 284 us: 1.09x faster (-8%)  |

Not significant (3): map_seq; map_par; apply
@jamadden

This comment has been minimized.

Member

jamadden commented Mar 25, 2018

For whatever reason, PyPy (pure-python) also appears a little bit faster, though that's probably within the margins of error:

Benchmark 27pypy_queue_master 27pypy_queue_cython2
bench_unbounded_queue_noblock 10.8 ns 9.68 ns: 1.12x faster (-10%)
bench_bounded_queue_noblock 10.9 ns 10.2 ns: 1.06x faster (-6%)
bench_bounded_queue_block 2.28 us 1.86 us: 1.23x faster (-18%)
bench_channel 1.91 us 1.85 us: 1.03x faster (-3%)
bench_bounded_queue_block_hub 1.07 us 984 ns: 1.09x faster (-8%)
bench_channel_hub 760 ns 693 ns: 1.10x faster (-9%)
bench_unbounded_priority_queue_noblock 186 ns 168 ns: 1.11x faster (-10%)
bench_bounded_priority_queue_noblock 183 ns 167 ns: 1.10x faster (-9%)
@arcivanov

This comment has been minimized.

Contributor

arcivanov commented Mar 25, 2018

Wow, pypy is so much faster.

jamadden added some commits Mar 25, 2018

@jamadden jamadden merged commit 821e7fc into master Mar 26, 2018

0 of 3 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details

@jamadden jamadden deleted the cython-waiter branch Mar 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment