From 1d92169e5b7adfa12fcea020022bcfc2d66c81ed Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 22 Sep 2023 00:05:38 -0500 Subject: [PATCH] Tweaked cache size to temporarily avoid pathological shrub overflows This will stop being a problem when we actually have btrees, but for now the fragmentation caused by byte-level syncs was easily enough to overflow an mdir when cache size is big. A smaller cache size is also nicer for debugging, since smaller cache sizes results in data getting flushed to disk earlier, which is easier to inspect than in-device buffers. And a 16-byte cache still provides decent test coverage over cache interactions. --- Also dropped inline_size to block_size/8. I realized while debugging that opened shrubs take up additional space until we sync, so we need to expect up to 2 temporary copies of shrubs when writing files. --- runners/bench_runner.h | 4 ++-- runners/test_runner.h | 4 ++-- tests/test_ftree.toml | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/runners/bench_runner.h b/runners/bench_runner.h index e88ee641..4d86ae25 100644 --- a/runners/bench_runner.h +++ b/runners/bench_runner.h @@ -138,8 +138,8 @@ intmax_t bench_define(size_t define); BENCH_DEF(BLOCK_SIZE, 0 ) \ BENCH_DEF(BLOCK_COUNT, DISK_SIZE/BLOCK_SIZE ) \ BENCH_DEF(DISK_SIZE, 1024*1024 ) \ - BENCH_DEF(CACHE_SIZE, lfs_max(64, lfs_max(READ_SIZE, PROG_SIZE))) \ - BENCH_DEF(INLINE_SIZE, BLOCK_SIZE/4 ) \ + BENCH_DEF(CACHE_SIZE, lfs_max(16, lfs_max(READ_SIZE, PROG_SIZE))) \ + BENCH_DEF(INLINE_SIZE, BLOCK_SIZE/8 ) \ BENCH_DEF(BUD_SIZE, BLOCK_SIZE/4 ) \ BENCH_DEF(LOOKAHEAD_SIZE, 16 ) \ BENCH_DEF(BLOCK_CYCLES, -1 ) \ diff --git a/runners/test_runner.h b/runners/test_runner.h index cd9df993..8331b4e3 100644 --- a/runners/test_runner.h +++ b/runners/test_runner.h @@ -137,8 +137,8 @@ intmax_t test_define(size_t define); TEST_DEF(BLOCK_SIZE, 0 ) \ TEST_DEF(BLOCK_COUNT, DISK_SIZE/BLOCK_SIZE ) \ TEST_DEF(DISK_SIZE, 1024*1024 ) \ - TEST_DEF(CACHE_SIZE, lfs_max(64, lfs_max(READ_SIZE, PROG_SIZE)) ) \ - TEST_DEF(INLINE_SIZE, BLOCK_SIZE/4 ) \ + TEST_DEF(CACHE_SIZE, lfs_max(16, lfs_max(READ_SIZE, PROG_SIZE)) ) \ + TEST_DEF(INLINE_SIZE, BLOCK_SIZE/8 ) \ TEST_DEF(BUD_SIZE, BLOCK_SIZE/4 ) \ TEST_DEF(LOOKAHEAD_SIZE, 16 ) \ TEST_DEF(BLOCK_CYCLES, -1 ) \ diff --git a/tests/test_ftree.toml b/tests/test_ftree.toml index 5dc6a21e..f25cb444 100644 --- a/tests/test_ftree.toml +++ b/tests/test_ftree.toml @@ -510,6 +510,7 @@ code = ''' # write files incrementally [cases.test_ftree_incr] defines.SIZE = ['CACHE_SIZE/2', '2*CACHE_SIZE'] +defines.CHUNK = [4, 1] defines.SYNC = [false, true] defines.REMOUNT = [false, true] reentrant = true @@ -530,7 +531,9 @@ code = ''' uint32_t prng = 42; for (lfs_size_t i = 0; i < SIZE; i++) { wbuf[i] = 'a' + (TEST_PRNG(&prng) % 26); - lfsr_file_write(&lfs, &file, &wbuf[i], 1) => 1; + } + for (lfs_size_t i = 0; i < SIZE; i += CHUNK) { + lfsr_file_write(&lfs, &file, &wbuf[i], CHUNK) => CHUNK; // sync? if (SYNC) {