Title: asyncio_websockets tests the implementation of `zlib`, not of Python · Issue #460 · python/pyperformance · GitHub
Open Graph Title: asyncio_websockets tests the implementation of `zlib`, not of Python · Issue #460 · python/pyperformance
X Title: asyncio_websockets tests the implementation of `zlib`, not of Python · Issue #460 · python/pyperformance
Description: I found out that the asyncio_websockets benchmark spends ~87% of runtime in zlib (i.e. in the shared library libz.so), or whatever compression library is the default on the system-under-test. In other words, asyncio_websockets tests the ...
Open Graph Description: I found out that the asyncio_websockets benchmark spends ~87% of runtime in zlib (i.e. in the shared library libz.so), or whatever compression library is the default on the system-under-test. In ot...
X Description: I found out that the asyncio_websockets benchmark spends ~87% of runtime in zlib (i.e. in the shared library libz.so), or whatever compression library is the default on the system-under-test. In ot...
Opengraph URL: https://github.com/python/pyperformance/issues/460
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"asyncio_websockets tests the implementation of `zlib`, not of Python","articleBody":"I found out that the `asyncio_websockets` [benchmark](https://github.com/python/pyperformance/blob/main/pyperformance/data-files/benchmarks/bm_asyncio_websockets/run_benchmark.py) spends ~87% of runtime in `zlib` (i.e. in the shared library `libz.so`), or whatever compression library is the default on the system-under-test.\n\nIn other words, `asyncio_websockets` tests the implementation of compression/decompression algorithms rather than anything to do with the Python interpreter or the `websockets` Python module. Websockets indeed enables compression by default: https://websockets.readthedocs.io/en/stable/topics/compression.html, excerpt from that official documentation:\n\u003e [connect()](https://websockets.readthedocs.io/en/stable/reference/asyncio/client.html#websockets.asyncio.client.connect) and [serve()](https://websockets.readthedocs.io/en/stable/reference/asyncio/server.html#websockets.asyncio.server.serve) enable compression by default because the reduction in network bandwidth is usually worth the additional memory and CPU cost.\n\n### Problem\n\nI believe this benchmark may not be measuring what's intended in its current form. For example, a replacement of `zlib` with `zlib-ng` or `zlib-rs` (which are newer drop-in replacement of `zlib`) may significantly affect the performance score of this benchmark, even though *nothing changed in Python and/or websockets implementations*. It is hard to root cause such performance modification, without knowing this detail about the `asyncio_websockets` benchmark.\n\nIt is also used in e.g. Phoronix testing, which may lead to unexpected conclusions for readers who aren't aware of this detail. Example: https://www.phoronix.com/review/cachyos-ubuntu-2510-f43/5.\n\n### Solutions\n\nI see the following solutions:\n1. Clearly document this behavior in https://pyperformance.readthedocs.io/benchmarks.html (in fact, there is no mention of websockets benchmark at all).\n2. Remove this benchmark, since the workload is dominated by native zlib rather than Python or websockets logic.\n3. Modify this benchmark to disable compression, as described here: https://websockets.readthedocs.io/en/stable/topics/compression.html#configuring-compression\n\nI'd lean towards option 3 (disabling compression) as it preserves the benchmark's intent while removing the zlib dependency from results. I'm happy to submit a PR if the maintainers agree.\n\n### Reproducing\n\nI ran it with a Amazon Linux 2023 docker container (OS distro similar to Fedora):\n```bash\ndocker run --rm -it amazonlinux:2023 /bin/bash # --\u003e\n\ndnf install -y pip perf dnf-utils\ndnf debuginfo-install zlib python3.9\npython3 -m pip install pyperformance\npython3 -m pip install websockets==11.0.3 pyperf==2.6.3\n\nperf record -g --call-graph dwarf -- \\\n python3 -u /usr/local/lib/python3.9/site-packages/pyperformance/data-files/benchmarks/bm_asyncio_websockets/run_benchmark.py\n```\n\nAfter running the benchmark, we can examine the resulting `perf.data` file:\n```console\n$ perf report --hierarchy\n...\n- 99.93% python3\n - 87.22% libz.so.1.2.11\n + 40.11% [.] inflate_fast\n + 36.28% [.] deflate_slow\n ...\n + 5.20% libpython3.9.so.1.0\n + 1.60% libc.so.6\n ...\n```\n\n---\n\nP.S. Thank you for maintaining the pyperformance project!","author":{"url":"https://github.com/dimakuv","@type":"Person","name":"dimakuv"},"datePublished":"2026-03-19T09:17:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/460/pyperformance/issues/460"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fa9ac3a6-45fb-33a3-4c9a-8d72e16e5e2e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 98AA:3D9B0D:1BCF5D0:285C45F:6A56554E |
| html-safe-nonce | 762a246cecfd96d635814afd996195b0d5bde2ac746f5c7916db429deb2f9994 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEFBOjNEOUIwRDoxQkNGNUQwOjI4NUM0NUY6NkE1NjU1NEUiLCJ2aXNpdG9yX2lkIjoiNjE4NjM0MjgwMTgzNzgwNjkyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 69973f9e62c770994865a08adc6d83b2be31ca289bd2f6c5ea9a113243bcec05 |
| hovercard-subject-tag | issue:4100381713 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/pyperformance/460/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f87dba1917c990d81c7251c6ed05de08a92ab6669988523a4afdfcba539c7a56/python/pyperformance/issues/460 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f87dba1917c990d81c7251c6ed05de08a92ab6669988523a4afdfcba539c7a56/python/pyperformance/issues/460 |
| og:image:alt | I found out that the asyncio_websockets benchmark spends ~87% of runtime in zlib (i.e. in the shared library libz.so), or whatever compression library is the default on the system-under-test. In ot... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dimakuv |
| hostname | github.com |
| expected-hostname | github.com |
| None | cffc1b7eb44a3dbb1e61c2a0523cad1f04e0368d730bf85ac498c992baf19e7d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/pyperformance git https://github.com/python/pyperformance.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 65949828 |
| octolytics-dimension-repository_nwo | python/pyperformance |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 65949828 |
| octolytics-dimension-repository_network_root_nwo | python/pyperformance |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 233d2274d9c68198aa6cb23d1db680b5c0b58bba |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width