Skip to content
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

[PR #9649/f2f5b056 backport][3.11] Avoid memory copy in the WebSocket reader for small payloads #9650

Conversation

patchback[bot]
Copy link
Contributor

@patchback patchback bot commented Nov 3, 2024

This is a backport of PR #9649 as merged into master (f2f5b05).

Only convert to bytearray when we know we are going to append messages or unmask. If the message comes in without being fragmented, we can avoid many conversions from bytes to bytearray which is the common case for small messages

Copy link

codspeed-hq bot commented Nov 3, 2024

CodSpeed Performance Report

Merging #9650 will improve performances by 36.8%

Comparing patchback/backports/3.11/f2f5b056e895e11eddd054132a20f83d2d6a7a07/pr-9649 (f3ed9e2) with 3.11 (4e398d7)

Summary

⚡ 2 improvements
✅ 9 untouched benchmarks

Benchmarks breakdown

Benchmark 3.11 patchback/backports/3.11/f2f5b056e895e11eddd054132a20f83d2d6a7a07/pr-9649 Change
test_one_thousand_large_round_trip_websocket_text_messages[pyloop] 32.9 ms 24 ms +36.8%
test_read_one_hundred_websocket_text_messages[pyloop] 490.7 µs 370.8 µs +32.32%

Copy link

codecov bot commented Nov 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.89%. Comparing base (4e398d7) to head (f3ed9e2).
Report is 1 commits behind head on 3.11.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             3.11    #9650   +/-   ##
=======================================
  Coverage   97.89%   97.89%           
=======================================
  Files         116      116           
  Lines       35492    35512   +20     
  Branches     4252     4256    +4     
=======================================
+ Hits        34744    34764   +20     
  Misses        559      559           
  Partials      189      189           
Flag Coverage Δ
CI-GHA 97.77% <100.00%> (+<0.01%) ⬆️
OS-Linux 97.47% <100.00%> (+<0.01%) ⬆️
OS-Windows 94.37% <34.37%> (-0.03%) ⬇️
OS-macOS 96.67% <34.37%> (-0.03%) ⬇️
Py-3.10.11 96.53% <34.37%> (-0.03%) ⬇️
Py-3.10.15 96.96% <100.00%> (+<0.01%) ⬆️
Py-3.11.10 97.04% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 96.62% <34.37%> (-0.03%) ⬇️
Py-3.12.7 97.51% <100.00%> (+<0.01%) ⬆️
Py-3.13.0 97.49% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 96.46% <34.37%> (-0.03%) ⬇️
Py-3.9.20 96.88% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.16 96.49% <100.00%> (+<0.01%) ⬆️
VM-macos 96.67% <34.37%> (-0.03%) ⬇️
VM-ubuntu 97.47% <100.00%> (+<0.01%) ⬆️
VM-windows 94.37% <34.37%> (-0.03%) ⬇️

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

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

@bdraco bdraco merged commit bd4e31e into 3.11 Nov 3, 2024
36 of 37 checks passed
@bdraco bdraco deleted the patchback/backports/3.11/f2f5b056e895e11eddd054132a20f83d2d6a7a07/pr-9649 branch November 3, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant