Skip to content

Benchmark and improve Nix NAR unpacking - #6

Draft
siraben wants to merge 9 commits into
siraben/bench-ghostty-terminal-displayfrom
siraben/nix-unpack-bench
Draft

Benchmark and improve Nix NAR unpacking#6
siraben wants to merge 9 commits into
siraben/bench-ghostty-terminal-displayfrom
siraben/nix-unpack-bench

Conversation

@siraben

@siraben siraben commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a repeatable Nix NAR unpack benchmark that prepares a riscv64 fakefs with Nix installed and a baked local NAR fixture.
  • Speed up fakefs metadata-heavy unpacking by tracking occupied stat-cache slots and updating matching cached inode entries instead of scanning/clearing the whole cache.
  • Batch fakefs metadata writes for exclusive file creates, mkdirs, symlinks, and fd metadata changes; pending paths/stats rows are overlaid for reads and flushed to SQLite in bulk.
  • Reuse cached fakefs fd metadata during fsetattr, and lower the direct-I/O threshold used by the measured candidate.

Benchmark

Fixture: RESTORES_PER_RUN=5 RUNS=5 WARMUPS=1 python3 benchmarks/nix_unpack/run.py

baseline_x5             avg 3.683045s
candidate_used_slot_x5  avg 3.635887s
path_stat_writeback_x5  avg 3.000889s

The post-run persistence smoke test confirmed 3256 restored paths and 3256 matching stat rows were flushed to meta.db.

Rejected experiments are documented in benchmarks/nix_unpack/README.md.

Validation

  • python3 -m py_compile benchmarks/nix_unpack/prepare.py benchmarks/nix_unpack/run.py
  • ninja -C build-perf-rv64 ish
  • meson test -C build-bench-rv64 rvinterp-selftest rvdecode-selftest
  • Persistence smoke test: one full restore, then sqlite3 meta.db counts for restored paths/stats both returned 3256

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.

1 participant