Move the srcToStore cache into fetchToStore()#507
Conversation
ba21538 to
14dbc06
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe per-session source-to-store path cache ( ChangessrcToStore cache migration to libfetchers
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
14dbc06 to
0ef0f14
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/libfetchers/fetch-settings.cc (1)
1-7: ⚡ Quick winInclude the concrete cache dependencies before constructing
srcToStore.Line 7 instantiates the concurrent map type, so this translation unit should directly include the full Boost container and complete
SourcePath/StorePath/Hashdefinitions rather than relying on transitive includes.♻️ Proposed include cleanup
`#include` "nix/fetchers/fetch-settings.hh" +#include "nix/store/store-api.hh" `#include` "nix/util/config-global.hh" +#include "nix/util/hash.hh" +#include "nix/util/source-path.hh" + +#include <boost/unordered/concurrent_flat_map.hpp> +#include <tuple>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/libfetchers/fetch-settings.cc` around lines 1 - 7, The Settings constructor on line 7 instantiates the srcToStore concurrent map type, but the file does not directly include the necessary headers for the Boost container and the complete type definitions needed for this instantiation. Add direct includes for the Boost concurrent map header and the full definitions of SourcePath, StorePath, and Hash types after the existing includes at the top of fetch-settings.cc. This ensures all concrete cache dependencies are available before the srcToStore member is constructed in the Settings::Settings() constructor.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/libfetchers/fetch-to-store.cc`:
- Around line 41-45: The fast-path cache in fetchToStore uses only the
SourcePath as the cache key on line 42 (getConcurrent call) and on line 125
(cache storage), but fetchToStore2 depends on additional parameters including
name, method, the current fingerprint, and store validity. This can return
incorrect cached results computed with different parameters. Modify the cache
key to include the full fetch identity (name, method, fingerprint) instead of
just the path. For entries without a fingerprint, ensure they are scoped
appropriately. Additionally, when returning a Copy mode hit from the cache on
line 43-44, add a temporary root and validate that the cached store path exists
and is valid in the current Store before returning it, to prevent returning
paths that are not accessible in the current context.
---
Nitpick comments:
In `@src/libfetchers/fetch-settings.cc`:
- Around line 1-7: The Settings constructor on line 7 instantiates the
srcToStore concurrent map type, but the file does not directly include the
necessary headers for the Boost container and the complete type definitions
needed for this instantiation. Add direct includes for the Boost concurrent map
header and the full definitions of SourcePath, StorePath, and Hash types after
the existing includes at the top of fetch-settings.cc. This ensures all concrete
cache dependencies are available before the srcToStore member is constructed in
the Settings::Settings() constructor.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a8bbf9ea-d41b-4f34-8b91-fdf50c231c0e
📒 Files selected for processing (7)
src/libexpr/eval.ccsrc/libexpr/include/nix/expr/eval.hhsrc/libfetchers/fetch-settings.ccsrc/libfetchers/fetch-to-store.ccsrc/libfetchers/include/nix/fetchers/fetch-mode.hhsrc/libfetchers/include/nix/fetchers/fetch-settings.hhsrc/libfetchers/include/nix/fetchers/fetch-to-store.hh
💤 Files with no reviewable changes (1)
- src/libexpr/include/nix/expr/eval.hh
This makes other users of fetchToStore() (in particular, `builtins.path`) benefit from the in-memory source path cache. This is useful for paths that lack a fingerprint (e.g. during non-flake evaluations using nix-instantiate).
0ef0f14 to
218796a
Compare
Motivation
This makes other users of fetchToStore() (in particular,
builtins.path) benefit from the in-memory source path cache. This is useful for paths that lack a fingerprint (e.g. during non-flake evaluations using nix-instantiate).Context
Summary by CodeRabbit