Tecnix dep tracking + eval caching#16
Conversation
…paths Previously, fetchToStore2 skipped the fingerprint cache entirely when a PathFilter was present, and had no caching for on-disk store paths that lacked an accessor-level fingerprint. Two changes: 1. Always call getFingerprint() regardless of filter. When a filter is present, prefix the cache key with "filtered:" to separate filtered and unfiltered results. This allows filtered paths with stable fingerprints (e.g., git-backed zones) to cache across evaluations. 2. For paths without an accessor fingerprint, check if the physical path is an immutable store path. If so, use "storePath:<physPath>" as a stable fingerprint for the SQLite cache. This avoids re-hashing on-disk nixpkgs store subpaths on every evaluation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a virtual getGitTreeHash() method to SourceAccessor that returns the git tree/blob SHA1 for a path, if available. Implement it in: - GitSourceAccessor: returns the OID from the git tree entry - GitExportIgnoreSourceAccessor: returns a synthetic hash incorporating "exportIgnore:" prefix to distinguish from raw trees - FilteringSourceAccessor: returns nullopt (arbitrary filters invalidate the tree hash) - MountedSourceAccessor: propagates through mounts - UnionSourceAccessor: returns first non-null result Use this in fetchToStore2 as a third cache tier: when the fingerprint cache misses (e.g., first run after cache clear), look up the git tree hash in the treeHashToNarHash SQLite cache. This maps git SHA1 tree OIDs to NAR SHA256 hashes, avoiding expensive NAR serialization when the mapping is already known from a previous evaluation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DirtyOverlaySourceAccessor (used for tectonix zones with uncommitted changes) had no getFingerprint() override, so it always returned nullopt. Combined with StorePath::random() generating a different virtual path each evaluation, the fetchToStore cache could never identify the same dirty zone across runs, causing expensive NAR serialization every time. Add a getFingerprint() that combines the base git accessor's fingerprint with the actual content of dirty files. Since dirty files are few and small, reading them is much cheaper than NAR-serializing the entire zone. The fingerprint changes when any dirty file is modified, ensuring cache correctness. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit 3edf54f.
Three changes to the dirty overlay accessor: 1. readFile/readLink now route clean files through the git ODB (base accessor) instead of always reading from disk. Only dirty files are read from disk. This is important because we can't always trust on-disk content for clean files (e.g. sparse checkouts). 2. Removed getPhysicalPath override — clean files should not expose disk paths since they're served from the git ODB. 3. Fingerprint computation now uses a HashSink and caches the result. The fingerprint is the base accessor's fingerprint (git tree SHA) plus a hash of dirty file paths and content, avoiding redundant re-computation across multiple fetchToStore calls in the same eval. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This wires in tracking into our source accessor and allows us to see exactly what files affect a given target.
* Flatten builtins.tecnixTargetNames * Clear file/import/input caches between targets to track dependencies correctly * Add --option tecnix-eval-cache false to disable eval cache * Record relative paths in dependency tracking * Add tests * General cleanup
Lots of slop in here but this makes the source access tracking stuff a lot more efficient. Now if we hit the eval cache we can produce the full dep graph in ~0.6s, and if we miss the eval cache we take ~20s instead of 10s of minutes. To avoid blowing away nix's caches between targets, we had to wire in the source tracking a lot more invasively.
a112149 to
c5f5f09
Compare
Fixed an issue with a dependency getting dropped for mutli-target evals. Parallel eval still has some issues.
Perf is back to being around ~26s while actually producing correct results for parallel eval now.
* Added multi-system eval * Got tecnix target eval caching back to ~1s.
Taking some inspiration from gecko profiles to pack the data more efficiently. Should help as tries expand.
* Fix under-tracking due to target discovery * Add fingerprints + negative lookups to output * Make tecnix builtins system-agnostic * Move system into target name and flatten dependency graph
* missing -> absent * store + load trie more efficiently from sqlite
* Build cached deps directly into values * Batch sqlite transactions * Clean up some dead code * Update design docs
* More cleanup
This was making our exact-access tracking (e.g. for imports) less consistent and visible.
* Fix some correctness bugs * Add tests for correctness bugs * Clear out some dead code
* Reintroduce legacy tectonix builtins * Split out tecnix builtins * Defer fingerprinting * Gate tracking
* Cleanup
* More cleanup
cbd204b to
1de745b
Compare
* Make patch less invasive
1de745b to
2aa9c58
Compare
* Unify tracking accumulators * Use concurrent flat map for access id lookups
* Clean up builtins
* More cleanup and optimization
* Update docs
a1da71a to
16aa196
Compare
* Re-add historical caching
* Make path to resolver explicit
* Support worldtree * Add worldtree mock and tests
* Reduce memory usage in new worldtree accessor
* Record filemode with blobs
a6d7530 to
ac3e8b7
Compare
EsterKais
left a comment
There was a problem hiding this comment.
Approving this. The design is clean, and the tests are genuinely great — they
check the hard stuff (shared values, negative lookups, dirty files, symlinks,
cross-commit invalidation), and they compare a target evaluated on its own against
the same target in a shared and a parallel run.
I'm approving rather than asking for changes first, and that's on purpose. Merging
this into tecnix doesn't actually change anything in World — we pin a specific
tecnix commit, so nothing moves until a separate bump PR. And everything I raise
below only matters on the dependency-graph path, which isn't driving any real
decision yet. Normal builds never touch the cache. So I'd rather land this now and
handle these as follow-ups before we turn the dependency graph on, instead of
growing the PR.
A few things my agent raised that we discussed — they seemed like concern points,
or at least clarification points, for me:
1. A .gitattributes change can fool the cache.
Git has a way to say "pretend this file isn't here" (export-ignore, via
.gitattributes). The cache remembers each file it read plus a fingerprint of
that file's contents. The catch is the fingerprint only tells us whether the
file's contents changed — it says nothing about whether the "pretend it isn't
here" rule changed. So if someone adds a rule that hides a file a target read, the
file's contents haven't changed, its fingerprint still matches, and the cache says
"nothing changed" and hands back a stale answer — even though a real re-run can't
see that file anymore.
In the code: getTecnixRepoAccessor turns on export-ignore but doesn't pass the
attribute info the way the zone accessors do in makeZoneAccessorOptions, and
GitPathFingerprintSourceAccessor::getFingerprint only records the raw object id
and mode, nothing about attributes.
The reassuring part: it's only risky in one direction (hiding a file that was
read; un-hiding is already caught), and some cases get caught by a directory
fingerprint. What are your thoughts?
2. Every value gets a little bigger the moment we bump World.
Merging here is harmless, but once World runs on this evaluator, every value is 8
bytes bigger (24 → 32), for all evaluation, whether tracking is on or not — plus a
small check when values finish and a branch in the force path. My worry is memory
and cache pressure on big evals, since value size is exactly the thing upstream
works hard to keep small. Is this something we need to worry about?
3. A shared function can quietly lose its file list — nice-to-have safety net, not a blocker.
accessSetForCopiedValue deliberately drops a function's file list when it's
reused and carries more than one file, so shared helpers don't smear their whole
history onto every target. I think that's the right call and I wouldn't change it.
The catch is it depends on resolver authors remembering to wrap file-reading
shared helpers in a scope, and nothing catches it if they forget. Instead of
changing the drop, could we add a CI test that evaluates targets both on their own
and in a shared/parallel run and diffs the results? A forgotten scope would show
up as the two runs disagreeing — so it turns "hope nobody forgets" into an
automatic check.
4. Just checking on the one lock.
The access-set graph uses a single lock for interning and for merging into each
target's total. The common operations stay off it, and the expensive flatten
happens after the workers finish, so I'd guess it's fine — but under heavy
parallel tracked eval, is that one lock going to hold back scaling, or is it
clearly off the hot path? Just want your read, not asking for a change.
These are all follow-ups or questions, not blockers — landing the foundation makes
sense to me.
robo summary 🤖