Skip to content

feat: improve performance of constructing ServiceInfo#1141

Merged
bdraco merged 3 commits into
masterfrom
ip_address_cache
Apr 1, 2023
Merged

feat: improve performance of constructing ServiceInfo#1141
bdraco merged 3 commits into
masterfrom
ip_address_cache

Conversation

@bdraco

@bdraco bdraco commented Apr 1, 2023

Copy link
Copy Markdown
Member

Since we see the same IP addresses over and over it pays off to cache the construction of them.

The cache hit rate is nearly 100% after the first time its seen.

2023-04-01 02:55:32.822 CRITICAL (SyncWorker_4) [homeassistant.components.profiler] Cache stats for lru_cache <function ip_address at 0x7f4e727dc790> at /usr/local/lib/python3.10/ipaddress.py: CacheInfo(hits=2239, misses=147, maxsize=1024, currsize=147)
2023-04-01 02:55:54.610 CRITICAL (SyncWorker_4) [homeassistant.components.profiler] Cache stats for lru_cache <function ip_address at 0x7f4e727dc790> at /usr/local/lib/python3.10/ipaddress.py: CacheInfo(hits=2434, misses=160, maxsize=1024, currsize=160)
2023-04-01 02:57:39.852 CRITICAL (SyncWorker_3) [homeassistant.components.profiler] Cache stats for lru_cache <function ip_address at 0x7f4e727dc790> at /usr/local/lib/python3.10/ipaddress.py: CacheInfo(hits=3589, misses=160, maxsize=1024, currsize=160)
2023-04-01 03:02:01.269 CRITICAL (SyncWorker_5) [homeassistant.components.profiler] Cache stats for lru_cache <function ip_address at 0x7f979a434820> at /usr/local/lib/python3.10/ipaddress.py: CacheInfo(hits=1072, misses=133, maxsize=1024, currsize=133)
2023-04-01 03:02:51.449 CRITICAL (SyncWorker_7) [homeassistant.components.profiler] Cache stats for lru_cache <function ip_address at 0x7f979a434820> at /usr/local/lib/python3.10/ipaddress.py: CacheInfo(hits=1571, misses=133, maxsize=1024, currsize=133)
2023-04-01 03:03:30.901 CRITICAL (SyncWorker_15) [homeassistant.components.profiler] Cache stats for lru_cache <function ip_address at 0x7f979a434820> at /usr/local/lib/python3.10/ipaddress.py: CacheInfo(hits=3347, misses=136, maxsize=1024, currsize=136)

Since we see the same IP addresses over and over it
pays off to cache the construction of them
@bdraco bdraco changed the title feat: cache ip address construction feat: improve performance of processing dns addresses ServiceInfo Apr 1, 2023
@bdraco bdraco changed the title feat: improve performance of processing dns addresses ServiceInfo feat: improve performance of processing dns addresses in ServiceInfo Apr 1, 2023
@codecov-commenter

codecov-commenter commented Apr 1, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (7246a34) 99.76% compared to head (b1d1c5e) 99.76%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1141   +/-   ##
=======================================
  Coverage   99.76%   99.76%           
=======================================
  Files          22       22           
  Lines        2603     2605    +2     
  Branches      456      456           
=======================================
+ Hits         2597     2599    +2     
  Misses          4        4           
  Partials        2        2           
Impacted Files Coverage Δ
src/zeroconf/__init__.py 100.00% <100.00%> (ø)
src/zeroconf/_services/__init__.py 100.00% <100.00%> (ø)
src/zeroconf/_services/info.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment thread src/zeroconf/_services/info.py Outdated
@bdraco bdraco marked this pull request as ready for review April 1, 2023 03:08
@bdraco bdraco changed the title feat: improve performance of processing dns addresses in ServiceInfo feat: improve performance of constructing ServiceInfo Apr 1, 2023
@bdraco bdraco merged commit 36d5b45 into master Apr 1, 2023
@bdraco bdraco deleted the ip_address_cache branch April 1, 2023 03:08
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.

2 participants