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

Restore 304 performance after fixing FileResponse replace race #10113

Merged
merged 8 commits into from
Dec 5, 2024
Merged

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Dec 5, 2024

Followup to #10101 to address the feedback in #10112

We can avoid opening the file is we are going to send a 304.

fixes #10112

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Dec 5, 2024
Copy link

codspeed-hq bot commented Dec 5, 2024

CodSpeed Performance Report

Merging #10113 will improve performances by 17.63%

Comparing 304_perf (360dd40) with master (9456955)

Summary

⚡ 1 improvements
✅ 46 untouched benchmarks

Benchmarks breakdown

Benchmark master 304_perf Change
test_simple_web_file_response_not_modified[pyloop] 67.6 ms 57.5 ms +17.63%

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.76%. Comparing base (9456955) to head (360dd40).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10113      +/-   ##
==========================================
+ Coverage   98.33%   98.76%   +0.42%     
==========================================
  Files         122      122              
  Lines       36951    36961      +10     
  Branches     4399     4410      +11     
==========================================
+ Hits        36337    36503     +166     
+ Misses        439      311     -128     
+ Partials      175      147      -28     
Flag Coverage Δ
CI-GHA 98.64% <100.00%> (+0.39%) ⬆️
OS-Linux 98.33% <100.00%> (+0.15%) ⬆️
OS-Windows 96.18% <100.00%> (?)
OS-macOS 97.44% <100.00%> (+0.09%) ⬆️
Py-3.10.11 97.28% <100.00%> (+0.29%) ⬆️
Py-3.10.15 97.82% <100.00%> (+<0.01%) ⬆️
Py-3.11.10 97.86% <100.00%> (+0.65%) ⬆️
Py-3.11.9 97.33% <100.00%> (?)
Py-3.12.7 98.39% <100.00%> (+1.18%) ⬆️
Py-3.13.0 97.20% <100.00%> (-0.01%) ⬇️
Py-3.13.1 98.30% <100.00%> (?)
Py-3.9.13 97.20% <100.00%> (?)
Py-3.9.20 97.78% <100.00%> (?)
Py-pypy7.3.16 97.35% <100.00%> (?)
VM-macos 97.44% <100.00%> (+0.09%) ⬆️
VM-ubuntu 98.33% <100.00%> (+0.15%) ⬆️
VM-windows 96.18% <100.00%> (?)

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 changed the title Restore 304 performance after fixing FileResponse replace race Restore 304 performance after fixing FileResponse replace race Dec 5, 2024
@bdraco bdraco added backport-3.11 Trigger automatic backporting to the 3.11 release branch by Patchback robot backport-3.12 Trigger automatic backporting to the 3.12 release branch by Patchback robot labels Dec 5, 2024
aiohttp/web_fileresponse.py Outdated Show resolved Hide resolved
aiohttp/web_fileresponse.py Outdated Show resolved Hide resolved
@bdraco bdraco marked this pull request as ready for review December 5, 2024 16:18
@bdraco bdraco merged commit 0130213 into master Dec 5, 2024
40 checks passed
@bdraco bdraco deleted the 304_perf branch December 5, 2024 17:06
Copy link
Contributor

patchback bot commented Dec 5, 2024

Backport to 3.11: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.11/0130213423d8d055ece27c36a4dcc96e524cbc1c/pr-10113

Backported as #10117

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

Copy link
Contributor

patchback bot commented Dec 5, 2024

Backport to 3.12: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.12/0130213423d8d055ece27c36a4dcc96e524cbc1c/pr-10113

Backported as #10118

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

patchback bot pushed a commit that referenced this pull request Dec 5, 2024
bdraco pushed a commit that referenced this pull request Dec 5, 2024
bdraco pushed a commit that referenced this pull request Dec 5, 2024
@steverep
Copy link
Member

steverep commented Dec 5, 2024

Nice! I might have guessed maybe 5% penalty from the buffered open. How big is the benchmark file (at least 4K I hope)?

@bdraco
Copy link
Member Author

bdraco commented Dec 5, 2024

The test uses this 11.1KB file https://github.com/aio-libs/aiohttp/blob/master/tests/sample.txt

The size of the file shouldn't make much (or maybe any) difference with most file systems unless its doing some type of read-ahead in the background since for most file systems, reading the metadata about the file doesn't require reading the contents.

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 backport-3.12 Trigger automatic backporting to the 3.12 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.

Restore performance of 304s after #10101
2 participants