From 14d0c4121c820683563eb61a82f3b3e77a0f5f61 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 15 Aug 2025 16:53:10 -0500 Subject: [PATCH] bmap: Dropped treediff buffers for now We're not currently using these (at the moment it's unclear if the original intention behind the treediff algorithms is worth pursuing), and they are showing up in our heap benchmarks. The good news is that means our heap benchmarks are working. Also saves a bit of code/ctx in bmap mode: code stack ctx before: 37024 2352 684 after: 37024 (+0.0%) 2352 (+0.0%) 684 (+0.0%) code stack ctx bmap before: 38752 2456 812 bmap after: 38704 (-0.1%) 2456 (+0.0%) 800 (-1.5%) --- lfs3.c | 36 +++++++++++++++++++----------------- lfs3.h | 35 +++++++++++++++++++---------------- runners/bench_runner.h | 2 -- runners/test_runner.h | 2 -- 4 files changed, 38 insertions(+), 37 deletions(-) diff --git a/lfs3.c b/lfs3.c index 4953da72..54a2e9d6 100644 --- a/lfs3.c +++ b/lfs3.c @@ -15449,18 +15449,19 @@ static int lfs3_init(lfs3_t *lfs3, uint32_t flags, lfs3_alloc_discard(lfs3); #endif - // setup treediff buffer - #if !defined(LFS3_RDONLY) && !defined(LFS3_2BONLY) && defined(LFS3_BMAP) - if (lfs3->cfg->treediff_buffer) { - lfs3->treediff.buffer = lfs3->cfg->treediff_buffer; - } else { - lfs3->treediff.buffer = lfs3_malloc(lfs3->cfg->treediff_size); - if (!lfs3->treediff.buffer) { - err = LFS3_ERR_NOMEM; - goto failed; - } - } - #endif +// TODO rm me +// // setup treediff buffer +// #if !defined(LFS3_RDONLY) && !defined(LFS3_2BONLY) && defined(LFS3_BMAP) +// if (lfs3->cfg->treediff_buffer) { +// lfs3->treediff.buffer = lfs3->cfg->treediff_buffer; +// } else { +// lfs3->treediff.buffer = lfs3_malloc(lfs3->cfg->treediff_size); +// if (!lfs3->treediff.buffer) { +// err = LFS3_ERR_NOMEM; +// goto failed; +// } +// } +// #endif // check that the size limits are sane #ifndef LFS3_RDONLY @@ -15649,11 +15650,12 @@ static int lfs3_deinit(lfs3_t *lfs3) { } #endif - #if !defined(LFS3_RDONLY) && !defined(LFS3_2BONLY) && defined(LFS3_BMAP) - if (!lfs3->cfg->treediff_buffer) { - lfs3_free(lfs3->treediff.buffer); - } - #endif +// TODO rm me +// #if !defined(LFS3_RDONLY) && !defined(LFS3_2BONLY) && defined(LFS3_BMAP) +// if (!lfs3->cfg->treediff_buffer) { +// lfs3_free(lfs3->treediff.buffer); +// } +// #endif return 0; } diff --git a/lfs3.h b/lfs3.h index 5ba8ae17..2ba8e7fa 100644 --- a/lfs3.h +++ b/lfs3.h @@ -465,12 +465,13 @@ struct lfs3_cfg { lfs3_size_t lookahead_size; #endif - // Size of the treediff buffer in bytes. A larger treediff buffer speeds - // up tree diffing in BMAPSLOW and BMAPFAST modes. The treediff buffer - // also uses a compact bitmap, and sizes >block_count/8 have no effect. - #if !defined(LFS3_RDONLY) && defined(LFS3_BMAP) - lfs3_size_t treediff_size; - #endif +// TODO rm me +// // Size of the treediff buffer in bytes. A larger treediff buffer speeds +// // up tree diffing in BMAPSLOW and BMAPFAST modes. The treediff buffer +// // also uses a compact bitmap, and sizes >block_count/8 have no effect. +// #if !defined(LFS3_RDONLY) && defined(LFS3_BMAP) +// lfs3_size_t treediff_size; +// #endif // Flags indicating what gc work to do during lfs3_gc calls. #ifdef LFS3_GC @@ -520,11 +521,12 @@ struct lfs3_cfg { void *lookahead_buffer; #endif - // Optional statically allocated treediff buffer. Must be treediff_size. - // By default lfs3_malloc is used to allocate this buffer. - #if !defined(LFS3_RDONLY) && defined(LFS3_BMAP) - void *treediff_buffer; - #endif +// TODO rm me +// // Optional statically allocated treediff buffer. Must be treediff_size. +// // By default lfs3_malloc is used to allocate this buffer. +// #if !defined(LFS3_RDONLY) && defined(LFS3_BMAP) +// void *treediff_buffer; +// #endif // Optional upper limit on length of file names in bytes. No downside for // larger names except the size of the info struct which is controlled by @@ -937,11 +939,12 @@ typedef struct lfs3 { } lookahead; #endif - #if !defined(LFS3_RDONLY) && !defined(LFS3_2BONLY) && defined(LFS3_BMAP) - struct lfs3_treediff { - uint8_t *buffer; - } treediff; - #endif +// TODO rm me +// #if !defined(LFS3_RDONLY) && !defined(LFS3_2BONLY) && defined(LFS3_BMAP) +// struct lfs3_treediff { +// uint8_t *buffer; +// } treediff; +// #endif #if !defined(LFS3_RDONLY) && !defined(LFS3_2BONLY) const lfs3_data_t *graft; diff --git a/runners/bench_runner.h b/runners/bench_runner.h index d4ed572e..51c5bd3a 100644 --- a/runners/bench_runner.h +++ b/runners/bench_runner.h @@ -114,7 +114,6 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size); BENCH_DEFINE(PCACHE_SIZE, LFS3_MAX(16, PROG_SIZE) ) \ BENCH_DEFINE(FILE_CACHE_SIZE, 16 ) \ BENCH_DEFINE(LOOKAHEAD_SIZE, 16 ) \ - BENCH_DEFINE(TREEDIFF_SIZE, 16 ) \ BENCH_DEFINE(GC_FLAGS, 0 ) \ BENCH_DEFINE(GC_STEPS, 0 ) \ BENCH_DEFINE(GC_COMPACT_THRESH, 0 ) \ @@ -155,7 +154,6 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size); #ifdef LFS3_BMAP #define BENCH_BMAP_CFG \ - .treediff_size = TREEDIFF_SIZE, \ .bmap_scan_thresh = BMAP_SCAN_THRESH, #else #define BENCH_BMAP_CFG diff --git a/runners/test_runner.h b/runners/test_runner.h index d22ead69..bb88de48 100644 --- a/runners/test_runner.h +++ b/runners/test_runner.h @@ -105,7 +105,6 @@ void test_permutation(size_t i, uint32_t *buffer, size_t size); TEST_DEFINE(PCACHE_SIZE, LFS3_MAX(16, PROG_SIZE) ) \ TEST_DEFINE(FILE_CACHE_SIZE, 16 ) \ TEST_DEFINE(LOOKAHEAD_SIZE, 16 ) \ - TEST_DEFINE(TREEDIFF_SIZE, 16 ) \ TEST_DEFINE(GC_FLAGS, 0 ) \ TEST_DEFINE(GC_STEPS, 0 ) \ TEST_DEFINE(GC_COMPACT_THRESH, 0 ) \ @@ -146,7 +145,6 @@ void test_permutation(size_t i, uint32_t *buffer, size_t size); #ifdef LFS3_BMAP #define TEST_BMAP_CFG \ - .treediff_size = TREEDIFF_SIZE, \ .bmap_scan_thresh = BMAP_SCAN_THRESH, #else #define TEST_BMAP_CFG