Add masked WebSocket read benchmarks and fix read benchmark backpressure - #13561
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13561 +/- ##
=======================================
Coverage 99.02% 99.02%
=======================================
Files 135 135
Lines 50454 50481 +27
Branches 2647 2650 +3
=======================================
+ Hits 49961 49988 +27
Misses 370 370
Partials 123 123
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
This will show as a regression but its really restoring the benchmark to original design. We missed |
Merging this PR will degrade performance by 94.92%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| 🆕 | test_read_one_hundred_masked_large_binary_websocket_messages |
N/A | 60.1 ms | N/A |
| 🆕 | test_read_one_hundred_masked_websocket_text_messages |
N/A | 667.1 µs | N/A |
| 👁 | test_read_one_hundred_websocket_text_messages |
464.2 µs | 580.3 µs | -20% |
| 👁 | test_read_large_binary_websocket_messages |
100.6 µs | 31,129.3 µs | -99.68% |
Comparing masked-ws-read-benchmarks (a82fe05) with master (4047e5b)
Footnotes
-
83 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
Confidence Score: 4/5The PR appears safe to merge, though the timed reader construction should be excluded to keep the parser benchmarks focused and comparable. The benchmark now avoids queue accumulation and exercises masked frames, but every measurement includes protocol, queue, and reader initialization that can be mistaken for parser performance. Files Needing Attention: tests/test_benchmarks_http_websocket.py Reviews (1): Last reviewed commit: "Add news fragment for benchmark changes" | Re-trigger Greptile |
Backport to 3.15: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 148205f on top of patchback/backports/3.15/148205f2fdc477ad3e4de0439d817b2a495ccf1e/pr-13561 Backporting merged PR #13561 into master
🤖 @patchback |
Backport to 3.14: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 148205f on top of patchback/backports/3.14/148205f2fdc477ad3e4de0439d817b2a495ccf1e/pr-13561 Backporting merged PR #13561 into master
🤖 @patchback |
…rks and fix read benchmark backpressure (#13562)
…rks and fix read benchmark backpressure (#13564)
What do these changes do?
The read benchmarks only fed unmasked frames, so the masked path a server takes for every frame from a client was invisible to CodSpeed; this adds masked variants for small text and large binary messages. It also fixes the existing read benchmarks; they stored an AssertionError from pause_reading after the eighth large frame and measured the early return path for the remaining feeds. The parser also stops parsing once the queue crosses its limit, so each benchmark round now uses a fresh reader with a queue limit the batch cannot reach.
CodSpeed will show a large regression on the large binary read benchmark; that is really restoring the benchmark to its original design. We missed
_upgraded = Truein the original, and after #11966 went in it would latch the AssertionError from pause_reading failing, so what looked like an improvement was the benchmark doing effectively nothing after 8 frames.Are there changes in behavior for the user?
No, benchmarks only.
Is it a substantial burden for the maintainers to support this?
No, the new benchmarks follow the shape of the existing ones.
Related issue number
Noticed while benchmarking #13559.
Checklist
CONTRIBUTORS.txtN/A, already listedCHANGES/foldername it
<issue_or_pr_num>.<type>.rst(e.g.588.bugfix.rst)if you don't have an issue number, change it to the pull request
number after creating the PR
.bugfix: A bug fix for something the maintainers deemed animproper undesired behavior that got corrected to match
pre-agreed expectations.
.feature: A new behavior, public APIs. That sort of stuff..deprecation: A declaration of future API removals and breakingchanges in behavior.
.breaking: When something public is removed in a breaking way.Could be deprecated in an earlier release.
.doc: Notable updates to the documentation structure or buildprocess.
.packaging: Notes for downstreams about unobvious side effectsand tooling. Changes in the test invocation considerations and
runtime assumptions.
.contrib: Stuff that affects the contributor experience. e.g.Running tests, building the docs, setting up the development
environment.
.misc: Changes that are hard to assign to any of the abovecategories.
Make sure to use full sentences with correct case and punctuation,
for example:
Use the past tense or the present tense a non-imperative mood,
referring to what's changed compared to the last released version
of this project.
Drafted with Claude Code (Fable 5); reviewed by @bdraco.