Skip to content

Add benchmark requests without session and alternating clients #10848

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

Merged
merged 3 commits into from
May 16, 2025

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented May 9, 2025

This was a bit of a blind spot in our benchmarks

noticed when I was looking at resolver object churn in #10847

This was a bit of a blind spot in our benchmarks

noticed when I was looking at resolver object churn in #10847
@bdraco bdraco added bot:chronographer:skip This PR does not need to include a change note 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 May 9, 2025
Copy link

codecov bot commented May 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.70%. Comparing base (1caddcf) to head (ecbeda6).
Report is 7 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10848   +/-   ##
=======================================
  Coverage   98.70%   98.70%           
=======================================
  Files         125      125           
  Lines       37858    37892   +34     
  Branches     2091     2094    +3     
=======================================
+ Hits        37366    37400   +34     
  Misses        343      343           
  Partials      149      149           
Flag Coverage Δ
CI-GHA 98.58% <100.00%> (+<0.01%) ⬆️
OS-Linux 98.27% <100.00%> (+<0.01%) ⬆️
OS-Windows 96.41% <100.00%> (+0.01%) ⬆️
OS-macOS 97.39% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 97.29% <100.00%> (+<0.01%) ⬆️
Py-3.10.17 97.61% <100.00%> (-0.22%) ⬇️
Py-3.11.12 97.92% <100.00%> (-0.01%) ⬇️
Py-3.11.9 97.38% <100.00%> (+0.01%) ⬆️
Py-3.12.10 98.35% <100.00%> (-0.01%) ⬇️
Py-3.13.3 98.34% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 97.16% <100.00%> (+<0.01%) ⬆️
Py-3.9.22 97.52% <100.00%> (-0.19%) ⬇️
Py-pypy7.3.16 93.50% <100.00%> (+8.93%) ⬆️
VM-macos 97.39% <100.00%> (+<0.01%) ⬆️
VM-ubuntu 98.27% <100.00%> (+<0.01%) ⬆️
VM-windows 96.41% <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.

Copy link

codspeed-hq bot commented May 9, 2025

CodSpeed Performance Report

Merging #10848 will not alter performance

Comparing benchmark_get_no_session (ecbeda6) with master (1caddcf)

Summary

✅ 58 untouched benchmarks
🆕 2 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 test_one_hundred_simple_get_requests_alternating_clients[pyloop] N/A 32.9 ms N/A
🆕 test_one_hundred_simple_get_requests_no_session[pyloop] N/A 83.6 ms N/A

@bdraco
Copy link
Member Author

bdraco commented May 9, 2025

As suspected

Image

And its reading files in the event loop 🙈

@Dreamsorcerer
Copy link
Member

At the same time, I don't think users should expect high performance from the simple API. We tell them to use a session in production code and even do it from the very first example in the docs..

@bdraco
Copy link
Member Author

bdraco commented May 9, 2025

At the same time, I don't think users should expect high performance from the simple API. We tell them to use a session in production code and even do it from the very first example in the docs..

I agree. We shouldn't put too much effort into improving this case. I think only the multi-session case matters

@bdraco
Copy link
Member Author

bdraco commented May 9, 2025

Yeah its the multisession case that actually matters.

Testing Home Assistant startup on a production instance:

116 setups used the shared session
47 created their own session
1 didn't use a session

48 DNSResolver objects in memory

@bdraco bdraco changed the title Add benchmark for simple GET requests without a session Add benchmark requests without session and alternating clients May 9, 2025
@bdraco bdraco marked this pull request as ready for review May 9, 2025 15:49
@bdraco bdraco requested a review from asvetlov as a code owner May 9, 2025 15:49
@bdraco
Copy link
Member Author

bdraco commented May 9, 2025

Checked a few more instances using Home Assistant’s profiler.dump_log_objects service, which uses gc to inspect objects in memory:

  • 2nd instance: 10 DNSResolver objects
  • 3rd instance: 247 DNSResolver objects

The number of DNSResolver instances varies significantly depending on the integrations in use, as many integration create their own session as the underlying libs are not aware of the shared session HA offers. This definitely seems worth looking into to reduce unnecessary duplication.

@bdraco bdraco merged commit 97eae19 into master May 16, 2025
40 checks passed
@bdraco bdraco deleted the benchmark_get_no_session branch May 16, 2025 19:30
Copy link
Contributor

patchback bot commented May 16, 2025

Backport to 3.11: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.11/97eae1940e472aebb16fe085a96aafee01728960/pr-10848

Backported as #10866

🤖 @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 May 16, 2025
Copy link
Contributor

patchback bot commented May 16, 2025

Backport to 3.12: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.12/97eae1940e472aebb16fe085a96aafee01728960/pr-10848

Backported as #10867

🤖 @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 May 16, 2025
bdraco added a commit that referenced this pull request May 16, 2025
…ssion and alternating clients (#10866)

Co-authored-by: J. Nick Koston <[email protected]>
resolver object churn in #10847
bdraco added a commit that referenced this pull request May 16, 2025
…ssion and alternating clients (#10867)

Co-authored-by: J. Nick Koston <[email protected]>
resolver object churn in #10847
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: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