perf(sync): enable FatFS fast seek for pack reads

Without CONFIG_FATFS_USE_FASTSEEK every long/backward lseek in the
263 MB pack walks the FAT cluster chain over SPI (~190 ms), and libgit2
pays ~8 such seeks per loose-object write. The CLMT makes lseek O(1)
for read-mode files; verified on device: far seek 198.7 -> 20.4 ms,
splice commit 6.5 -> 2.8 s.
This commit is contained in:
Julien Calixte
2026-07-13 00:02:42 +02:00
parent 2c24ece3a5
commit 2c1c590c9e

View File

@@ -44,6 +44,21 @@ CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_USE_MALLOC=y
# FatFS fast seek (sync-latency root cause, 2026-07-12). Without it, lseek
# resolves by walking the file's FAT cluster chain over SPI — forward from the
# current position, from the CHAIN HEAD on any backward seek. sd_bench measured
# ~190 ms per long seek into the 263 MB packfile (5.8 ms at offset 0), and
# libgit2 pays ~8 such seeks per loose-object write via p_mmap's lseek+read →
# the ~1.5 s/object commit cost (docs/tradeoff-curves/sync-commit-staging.md).
# Fast seek builds an in-memory cluster-link map (CLMT) per READ-mode file,
# making lseek O(1); write-mode files transparently fall back to the walk. The
# buffer is per-open-file, 4 B × size: 256 words = 1 KB, covering ~127 fragments
# (the default 64 covers ~31 — a freshly-provisioned pack is near-contiguous,
# but don't let card aging silently disable the fix; vfs_fat falls back to slow
# seeks when the map doesn't fit).
CONFIG_FATFS_USE_FASTSEEK=y
CONFIG_FATFS_FAST_SEEK_BUFFER_SIZE=256
# Silence the legacy-I2C boot warning. esp-idf-hal's i2c.rs is always compiled
# and binds the old `driver/i2c.h` API, so the legacy driver's TU (and its
# `__attribute__((constructor))` deprecation warning) gets linked into every