You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(test): replace copyDir with hardLinkDir for mprcontents/ isolation
CPU profiling (go tool pprof -top -cum) showed that 44% of repos test
CPU was spent in copyDir / filepath.WalkDir copying the 19 MB mprcontents/
tree (370 .mxunit files) for every test, and 24% in os.RemoveAll cleanup.
Systemic fix: mprcontents/ unit files are immutable once written — the
Writer never modifies existing .mxunit files in place; it only creates new
files with fresh UUIDs. This makes hard links safe as an isolation
strategy. hardLinkDir() replaces copyDir() for the mprcontents/ subtree:
- On same-device filesystems (CI single-partition, etc.): os.Link is O(1),
no data transfer at all.
- On cross-device setups (e.g. /tmp on a different partition): automatic
EXDEV fallback to io.Copy, identical to the previous behaviour.
The .mpr SQLite file (68 KB) is still real-copied because the Writer
commits WAL changes into it.
Also remove a leftover double-read in reader_units.go: listUnitsByTypeV2
no longer re-reads unit files that buildUnitCache already read to extract
the type; the cache now covers both metadata and avoids the second pass.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
0 commit comments