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 #8667/406cd2c7 backport][3.10] Improve performance of generating random WebSocket mask #8668

Conversation

patchback[bot]
Copy link
Contributor

@patchback patchback bot commented Aug 9, 2024

This is a backport of PR #8667 as merged into master (406cd2c).

What do these changes do?

The mask was being generated with randint and than converted to bytes. We can skip a few steps and generate it with getrandbits() and pack it into bytes.

related RFC: https://datatracker.ietf.org/doc/html/rfc6455#section-5.3

Are there changes in behavior for the user?

No

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

no

I was looking at pings and noticed that most of the time is spent in randrange
Screenshot 2024-08-08 at 9 13 27 PM

Copy link

codecov bot commented Aug 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.71%. Comparing base (b4ad882) to head (3266a72).
Report is 198 commits behind head on 3.10.

Additional details and impacted files
@@           Coverage Diff           @@
##             3.10    #8668   +/-   ##
=======================================
  Coverage   97.71%   97.71%           
=======================================
  Files         108      108           
  Lines       33980    33981    +1     
  Branches     4047     4047           
=======================================
+ Hits        33204    33205    +1     
  Misses        579      579           
  Partials      197      197           
Flag Coverage Δ
CI-GHA 97.61% <100.00%> (+<0.01%) ⬆️
OS-Linux 97.29% <100.00%> (-0.01%) ⬇️
OS-Windows 94.81% <100.00%> (+<0.01%) ⬆️
OS-macOS 96.97% <100.00%> (+0.01%) ⬆️
Py-3.10.11 97.05% <100.00%> (+<0.01%) ⬆️
Py-3.10.14 97.00% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 97.24% <100.00%> (+<0.01%) ⬆️
Py-3.12.4 97.33% <100.00%> (+<0.01%) ⬆️
Py-3.8.10 94.42% <100.00%> (+<0.01%) ⬆️
Py-3.8.18 96.79% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 96.94% <100.00%> (+<0.01%) ⬆️
Py-3.9.19 96.89% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.16 96.48% <100.00%> (+<0.01%) ⬆️
VM-macos 96.97% <100.00%> (+0.01%) ⬆️
VM-ubuntu 97.29% <100.00%> (-0.01%) ⬇️
VM-windows 94.81% <100.00%> (+<0.01%) ⬆️

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 dbcdb16 into 3.10 Aug 9, 2024
33 of 34 checks passed
@bdraco bdraco deleted the patchback/backports/3.10/406cd2c7512db5a3f7e389be926eedd5a3bf6dc4/pr-8667 branch August 9, 2024 14:11
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