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 account to open an issue and contact its maintainers and the community.

By clicking “Sign up for ”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on ? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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
@bdracobdraco added bot:chronographer:skipThis PR does not need to include a change notebackport-3.11Trigger automatic backporting to the 3.11 release branch by back robotbackport-3.12Trigger automatic backporting to the 3.12 release branch by back robotlabels May 9, 2025
@codecovCodecov
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 2 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           
FlagCoverage Δ
CI-GHA98.58% <100.00%> (+<0.01%)⬆️
OS-Linux98.27% <100.00%> (+<0.01%)⬆️
OS-Windows96.41% <100.00%> (+0.01%)⬆️
OS-macOS97.39% <100.00%> (+<0.01%)⬆️
Py-3.10.1197.29% <100.00%> (+<0.01%)⬆️
Py-3.10.1797.61% <100.00%> (-0.22%)⬇️
Py-3.11.1297.92% <100.00%> (-0.01%)⬇️
Py-3.11.997.38% <100.00%> (+0.01%)⬆️
Py-3.12.1098.35% <100.00%> (-0.01%)⬇️
Py-3.13.398.34% <100.00%> (+<0.01%)⬆️
Py-3.9.1397.16% <100.00%> (+<0.01%)⬆️
Py-3.9.2297.52% <100.00%> (-0.19%)⬇️
Py-pypy7.3.1693.50% <100.00%> (+8.93%)⬆️
VM-macos97.39% <100.00%> (+<0.01%)⬆️
VM-ubuntu98.27% <100.00%> (+<0.01%)⬆️
VM-windows96.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.

@codspeed-hqCodSpeed HQ
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

BenchmarkBASEHEADChange
🆕test_one_hundred_simple_get_requests_alternating_clients[pyloop]N/A32.9 msN/A
🆕test_one_hundred_simple_get_requests_no_session[pyloop]N/A83.6 msN/A

@bdraco
Copy link
Member Author

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

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

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

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

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.

Sign up for free to join this conversation on . Already have an account? Sign in to comment
Labels
backport-3.11Trigger automatic backporting to the 3.11 release branch by back robotbackport-3.12Trigger automatic backporting to the 3.12 release branch by back robotbot:chronographer:skipThis PR does not need to include a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants