Singleflight Python health checks with cached interpreter info#1381
Singleflight Python health checks with cached interpreter info#1381
Conversation
Add singleflight caching for Python interpreter info to dedupe parallel health checks.
There was a problem hiding this comment.
Pull request overview
This PR adds singleflight caching for Python interpreter information queries to prevent duplicate work when multiple health checks run in parallel. The implementation uses the uv-once-map crate to ensure only one query executes at a time for each Python interpreter path.
Changes:
- Introduced a global cache (
PYTHON_INFO_CACHE) usingOnceMapto deduplicate concurrent Python info queries - Created new
query_python_info_cachedfunction that wraps the existing query logic with caching - Updated
check_healthmethods in Python and Pygrep language implementations to use the cached version
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/prek/src/languages/python/python.rs | Added caching infrastructure with OnceMap, implemented query_python_info_cached function, and updated check_health to use cached queries |
| crates/prek/src/languages/python/mod.rs | Updated exports to replace query_python_info with query_python_info_cached |
| crates/prek/src/languages/pygrep/pygrep.rs | Updated check_health to use query_python_info_cached |
| crates/prek/Cargo.toml | Added uv-once-map dependency |
| Cargo.toml | Added uv-once-map version constraint |
| Cargo.lock | Lock file updates for new dependencies |
| .pre-commit-config.yaml | Added trailing-whitespace check hook |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Cargo Bloat ComparisonBinary size change: -0.44% (22.5 MiB → 22.4 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1381 +/- ##
==========================================
- Coverage 90.34% 90.30% -0.04%
==========================================
Files 81 81
Lines 16122 16143 +21
==========================================
+ Hits 14565 14578 +13
- Misses 1557 1565 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add singleflight caching for Python interpreter info to dedupe parallel health checks.