Skip to content

Drop the mock protocol from the multipart benchmarks - #13515

Merged
Dreamsorcerer merged 1 commit into
masterfrom
multipart-bench-protocol
Aug 22, 2026
Merged

Drop the mock protocol from the multipart benchmarks#13515
Dreamsorcerer merged 1 commit into
masterfrom
multipart-bench-protocol

Conversation

@bdraco

@bdraco bdraco commented Aug 22, 2026

Copy link
Copy Markdown
Member

What do these changes do?

The multipart benchmarks built their StreamReader on a mock.Mock protocol, so every chunk read went through a mock resume_reading() call; that was about a third of the measured time and it is sensitive to the runner environment, which showed up as a spurious 10% regression on #13514. Use a BaseProtocol subclass with no-op flow control instead, as the websocket benchmarks already do.

Are there changes in behavior for the user?

No, benchmarks only.

Is it a substantial burden for the maintainers to support this?

No.

Related issue number

Follow up to #13509, noise seen on #13514.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes N/A
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt N/A
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES/ folder N/A
    • 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 Fable 5; reviewed by @bdraco.

@bdraco bdraco added backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot backport-3.15 Trigger automatic backporting to the 3.15 release branch by Patchback robot bot:chronographer:skip This PR does not need to include a change note labels Aug 22, 2026
@bdraco
bdraco marked this pull request as ready for review August 22, 2026 18:01
@bdraco
bdraco requested a review from asvetlov as a code owner August 22, 2026 18:01
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.02%. Comparing base (2d9c5c1) to head (8b209ee).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #13515   +/-   ##
=======================================
  Coverage   99.02%   99.02%           
=======================================
  Files         133      133           
  Lines       49924    49927    +3     
  Branches     2594     2594           
=======================================
+ Hits        49439    49442    +3     
  Misses        366      366           
  Partials      119      119           
Flag Coverage Δ
Autobahn 22.00% <80.00%> (+<0.01%) ⬆️
CI-GHA 98.93% <100.00%> (+<0.01%) ⬆️
OS-Linux 98.70% <100.00%> (+<0.01%) ⬆️
OS-Windows 97.04% <100.00%> (+<0.01%) ⬆️
OS-macOS 97.96% <100.00%> (-0.01%) ⬇️
Py-3.10 98.15% <100.00%> (+<0.01%) ⬆️
Py-3.11 98.39% <100.00%> (-0.01%) ⬇️
Py-3.12 98.47% <100.00%> (-0.01%) ⬇️
Py-3.13 98.46% <100.00%> (+<0.01%) ⬆️
Py-3.14 98.48% <100.00%> (+<0.01%) ⬆️
Py-3.14t 97.58% <100.00%> (+<0.01%) ⬆️
Py-pypy-3.11 97.43% <100.00%> (-0.01%) ⬇️
VM-macos 97.96% <100.00%> (-0.01%) ⬇️
VM-ubuntu 98.70% <100.00%> (+<0.01%) ⬆️
VM-windows 97.04% <100.00%> (+<0.01%) ⬆️
cython-coverage 83.02% <ø> (ø)

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.

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge because the benchmark protocol stub supports all flow-control interactions reached by these pre-buffered streams.

The change is confined to benchmark setup, and the replacement protocol provides the connected state and pause/resume methods used by StreamReader without altering user-facing multipart behavior.

Reviews (1): Last reviewed commit: "Drop the mock protocol from the multipar..." | Re-trigger Greptile

@codspeed-hq

codspeed-hq Bot commented Aug 22, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 18.63%

⚠️ 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 improved benchmarks
✅ 84 untouched benchmarks
⏩ 83 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
test_read_base64_part 18.5 ms 15.5 ms +19.23%
test_read_chunk_base64_realignment 7.5 ms 6.4 ms +18.04%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing multipart-bench-protocol (8b209ee) with master (2d9c5c1)

Open in CodSpeed

Footnotes

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

@Dreamsorcerer
Dreamsorcerer merged commit 495e778 into master Aug 22, 2026
55 of 56 checks passed
@Dreamsorcerer
Dreamsorcerer deleted the multipart-bench-protocol branch August 22, 2026 18:29
@patchback

patchback Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Backport to 3.15: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.15/495e778360d1924da63e16dba0f0d76baf56a56a/pr-13515

Backported as #13518

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@patchback

patchback Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Backport to 3.14: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.14/495e778360d1924da63e16dba0f0d76baf56a56a/pr-13515

Backported as #13519

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

bdraco added a commit that referenced this pull request Aug 22, 2026
…ultipart benchmarks (#13519)

Co-authored-by: J. Nick Koston <nick@koston.org>
Fixes
#123
bdraco added a commit that referenced this pull request Aug 23, 2026
…ultipart benchmarks (#13518)

Co-authored-by: J. Nick Koston <nick@koston.org>
Fixes
#123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot backport-3.15 Trigger automatic backporting to the 3.15 release branch by Patchback robot bot:chronographer:skip This PR does not need to include a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants