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

Reduce memcpy with chunked encoding #9838

Closed
wants to merge 2 commits into from
Closed

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Nov 12, 2024

Screenshot 2024-11-12 at 10 45 28 AM

finishing a chunk has a lot of memcpy. We can switch it to a b"".join() since it has a more efficient implementation in https://github.com/python/cpython/blob/91f4908798074db6c41925b4417bee1f933aca93/Objects/stringlib/join.h#L36 vs constructing a new bytes string for every add operation

Copy link

codspeed-hq bot commented Nov 12, 2024

CodSpeed Performance Report

Merging #9838 will improve performances by 21.36%

Comparing avoid_mem_cpy_chunks (636206a) with master (32ccfc9)

Summary

⚡ 1 improvements
✅ 22 untouched benchmarks

Benchmarks breakdown

Benchmark master avoid_mem_cpy_chunks Change
test_one_hundred_get_requests_with_512kib_chunked_payload[pyloop] 262.3 ms 216.1 ms +21.36%

@bdraco bdraco added backport-3.10 backport-3.11 Trigger automatic backporting to the 3.11 release branch by Patchback robot labels Nov 12, 2024
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Nov 12, 2024
@bdraco
Copy link
Member Author

bdraco commented Nov 12, 2024

Maybe we should use writelines

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.70%. Comparing base (32ccfc9) to head (636206a).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9838      +/-   ##
==========================================
- Coverage   98.70%   98.70%   -0.01%     
==========================================
  Files         118      118              
  Lines       36148    36145       -3     
  Branches     4294     4294              
==========================================
- Hits        35680    35677       -3     
  Misses        315      315              
  Partials      153      153              
Flag Coverage Δ
CI-GHA 98.59% <100.00%> (-0.01%) ⬇️
OS-Linux 98.27% <100.00%> (-0.01%) ⬇️
OS-Windows 96.07% <100.00%> (-0.01%) ⬇️
OS-macOS 97.36% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 97.20% <100.00%> (-0.01%) ⬇️
Py-3.10.15 97.76% <100.00%> (-0.01%) ⬇️
Py-3.11.10 97.80% <100.00%> (-0.05%) ⬇️
Py-3.11.9 97.26% <100.00%> (+<0.01%) ⬆️
Py-3.12.7 98.35% <100.00%> (-0.01%) ⬇️
Py-3.13.0 98.33% <100.00%> (+0.05%) ⬆️
Py-3.9.13 97.12% <100.00%> (-0.01%) ⬇️
Py-3.9.20 97.68% <100.00%> (-0.05%) ⬇️
Py-pypy7.3.16 97.29% <100.00%> (-0.01%) ⬇️
VM-macos 97.36% <100.00%> (+<0.01%) ⬆️
VM-ubuntu 98.27% <100.00%> (-0.01%) ⬇️
VM-windows 96.07% <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
Copy link
Member Author

bdraco commented Nov 12, 2024

#9839 is likely going to be a better solution

@bdraco
Copy link
Member Author

bdraco commented Nov 12, 2024

replaced by #9839

@bdraco bdraco closed this Nov 12, 2024
@bdraco bdraco deleted the avoid_mem_cpy_chunks branch November 15, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-3.11 Trigger automatic backporting to the 3.11 release branch by Patchback robot 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