Skip to content

[PR #13561/148205f2 backport][3.14] Add masked WebSocket read benchmarks and fix read benchmark backpressure - #13562

Merged
bdraco merged 1 commit into
aio-libs:3.14from
bdraco:patchback/backports/3.14/148205f2fdc477ad3e4de0439d817b2a495ccf1e/pr-13561
Aug 28, 2026
Merged

[PR #13561/148205f2 backport][3.14] Add masked WebSocket read benchmarks and fix read benchmark backpressure#13562
bdraco merged 1 commit into
aio-libs:3.14from
bdraco:patchback/backports/3.14/148205f2fdc477ad3e4de0439d817b2a495ccf1e/pr-13561

Conversation

@bdraco

@bdraco bdraco commented Aug 28, 2026

Copy link
Copy Markdown
Member

This is a backport of PR #13561 as merged into master (148205f).

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 = True in 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

  • I think the code is well written
  • Unit tests for the changes exist N/A, this is a benchmark change
  • Documentation reflects the changes N/A
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt N/A, already listed
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES/ folder
    • name 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 an
        improper 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 breaking
        changes 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 build
        process.
      • .packaging: Notes for downstreams about unobvious side effects
        and 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 above
        categories.
    • Make sure to use full sentences with correct case and punctuation,
      for example:

      Fixed issue with non-ascii contents in doctest text files
      -- by :user:`contributor-gh-handle`.

      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.

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Aug 28, 2026
@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge because the changed benchmark paths parse their complete batches and the new masked frames are valid.

The configured queue and message limits accommodate all benchmark inputs, fresh reader state prevents prior rounds from affecting later measurements, and both masked frame variants reach the intended parser unmasking path.

Reviews (1): Last reviewed commit: "Add masked WebSocket read benchmarks and..." | Re-trigger Greptile

@bdraco
bdraco enabled auto-merge (squash) August 28, 2026 03:03
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.21%. Comparing base (011c082) to head (201af20).
⚠️ Report is 1 commits behind head on 3.14.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             3.14   #13562   +/-   ##
=======================================
  Coverage   96.21%   96.21%           
=======================================
  Files         160      160           
  Lines       51143    51170   +27     
  Branches     2780     2783    +3     
=======================================
+ Hits        49205    49232   +27     
  Misses       1756     1756           
  Partials      182      182           
Flag Coverage Δ
CI-GHA 96.20% <100.00%> (+<0.01%) ⬆️
OS-Linux 95.98% <100.00%> (+<0.01%) ⬆️
OS-Windows 93.68% <100.00%> (+<0.01%) ⬆️
OS-macOS 95.14% <100.00%> (+<0.01%) ⬆️
Py-3.10 95.36% <100.00%> (+<0.01%) ⬆️
Py-3.11 95.60% <100.00%> (+<0.01%) ⬆️
Py-3.12 95.69% <100.00%> (+0.01%) ⬆️
Py-3.13 95.67% <100.00%> (-0.01%) ⬇️
Py-3.14 95.78% <100.00%> (+<0.01%) ⬆️
Py-3.14t 94.79% <100.00%> (+0.01%) ⬆️
Py-pypy-3.11 94.63% <100.00%> (-0.01%) ⬇️
VM-macos 95.14% <100.00%> (+<0.01%) ⬆️
VM-ubuntu 95.98% <100.00%> (+<0.01%) ⬆️
VM-windows 93.68% <100.00%> (+<0.01%) ⬆️
cython-coverage 78.94% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codspeed-hq

codspeed-hq Bot commented Aug 28, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 93.64%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 2 (👁 2) regressed benchmarks
✅ 78 untouched benchmarks
🆕 2 new benchmarks
⏩ 7 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 test_read_one_hundred_masked_large_binary_websocket_messages[pyloop] N/A 15.9 ms N/A
🆕 test_read_one_hundred_masked_websocket_text_messages[pyloop] N/A 299.1 µs N/A
👁 test_read_one_hundred_websocket_text_messages[pyloop] 213 µs 264.7 µs -19.53%
👁 test_read_large_binary_websocket_messages[pyloop] 45 µs 8,934.1 µs -99.5%

Comparing bdraco:patchback/backports/3.14/148205f2fdc477ad3e4de0439d817b2a495ccf1e/pr-13561 (201af20) with 3.14 (011c082)

Open in CodSpeed

Footnotes

  1. 7 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.

@bdraco
bdraco merged commit ec9e59d into aio-libs:3.14 Aug 28, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant