From 2c1c590c9e62901acf585d6adfec44074d4aacfc Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Mon, 13 Jul 2026 00:02:42 +0200 Subject: [PATCH] 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. --- firmware/sdkconfig.defaults | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/firmware/sdkconfig.defaults b/firmware/sdkconfig.defaults index 885b163..bee6fa4 100644 --- a/firmware/sdkconfig.defaults +++ b/firmware/sdkconfig.defaults @@ -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