From 6cd29bede23c0ad024f10f4d98a72daa2c93e0c6 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 7 Feb 2025 01:28:46 -0600 Subject: [PATCH] Dropped lfs->cfg->inline_size Now that we no longer have bmoss files, inline_size and shrub_size are effectively the same thing. We weren't using this, so no code change, but it does save a word of ctx: code stack ctx before: 36280 2576 640 after: 36280 (+0.0%) 2576 (+0.0%) 636 (-0.6%) --- lfs.c | 11 ----------- lfs.h | 14 +++++++------- runners/bench_runner.h | 4 +--- runners/test_runner.h | 4 +--- tests/test_ck.toml | 6 +++--- tests/test_fwrite.toml | 4 ++-- tests/test_powerloss.toml | 6 +++--- tests/test_traversal.toml | 14 +++++++------- 8 files changed, 24 insertions(+), 39 deletions(-) diff --git a/lfs.c b/lfs.c index 614afa64..5ab357c7 100644 --- a/lfs.c +++ b/lfs.c @@ -10717,15 +10717,6 @@ static inline lfs_size_t lfsr_file_buffersize(lfs_t *lfs, : lfs->cfg->file_buffer_size; } -static inline lfs_size_t lfsr_file_inlinesize(lfs_t *lfs, - const lfsr_file_t *file) { - return lfs_min( - lfsr_file_buffersize(lfs, file), - lfs_min( - lfs->cfg->inline_size, - lfs->cfg->fragment_size)); -} - static inline lfs_off_t lfsr_file_size_(const lfsr_file_t *file) { return lfs_max( file->buffer.pos + file->buffer.size, @@ -12832,8 +12823,6 @@ static int lfs_init(lfs_t *lfs, uint32_t flags, LFS_ASSERT(lfs->cfg->gc_compact_thresh == (lfs_size_t)-1 || lfs->cfg->gc_compact_thresh <= lfs->cfg->block_size); - // inline_size must be <= block_size/4 - LFS_ASSERT(lfs->cfg->inline_size <= lfs->cfg->block_size/4); // shrub_size must be <= block_size/4 LFS_ASSERT(lfs->cfg->shrub_size <= lfs->cfg->block_size/4); // fragment_size must be <= block_size/4 diff --git a/lfs.h b/lfs.h index 02ef4580..8c5faee3 100644 --- a/lfs.h +++ b/lfs.h @@ -422,17 +422,17 @@ struct lfs_config { // // can help bound the metadata compaction time. Must be <= block_size. // // Defaults to block_size when zero. // lfs_size_t metadata_max; +// +// // Maximum size of inlined files in bytes. Inlined files decrease storage +// // requirements, but may impact metadata-related performance. Must be <= +// // block_size/4. +// // +// // 0 disables inline files. +// lfs_size_t inline_size; // TODO these are pretty low-level details, should we have reasonable // defaults? need to benchmark. - // Maximum size on inlined files in bytes. Inlined files decrease storage - // requirements, but may impact metadata-related performance. Must be <= - // block_size/4. - // - // 0 disables inline files. - lfs_size_t inline_size; - // Maximum size of inlined trees (shrubs) in bytes. Shrubs reduce B-tree // root overhead, but may impact metadata-related performance. Must be <= // blocksize/4. diff --git a/runners/bench_runner.h b/runners/bench_runner.h index 4d31eec0..3344e563 100644 --- a/runners/bench_runner.h +++ b/runners/bench_runner.h @@ -117,8 +117,7 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size); BENCH_DEFINE(GC_FLAGS, 0 ) \ BENCH_DEFINE(GC_STEPS, 0 ) \ BENCH_DEFINE(GC_COMPACT_THRESH, 0 ) \ - BENCH_DEFINE(INLINE_SIZE, BLOCK_SIZE/4 ) \ - BENCH_DEFINE(SHRUB_SIZE, INLINE_SIZE ) \ + BENCH_DEFINE(SHRUB_SIZE, BLOCK_SIZE/4 ) \ BENCH_DEFINE(FRAGMENT_SIZE, BLOCK_SIZE/8 ) \ BENCH_DEFINE(CRYSTAL_THRESH, BLOCK_SIZE/8 ) \ BENCH_DEFINE(ERASE_VALUE, 0xff ) \ @@ -147,7 +146,6 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size); .lookahead_size = LOOKAHEAD_SIZE, \ BENCH_GC_CFG \ .gc_compact_thresh = GC_COMPACT_THRESH, \ - .inline_size = INLINE_SIZE, \ .shrub_size = SHRUB_SIZE, \ .fragment_size = FRAGMENT_SIZE, \ .crystal_thresh = CRYSTAL_THRESH, diff --git a/runners/test_runner.h b/runners/test_runner.h index 9063b8c1..045752b6 100644 --- a/runners/test_runner.h +++ b/runners/test_runner.h @@ -108,8 +108,7 @@ void test_permutation(size_t i, uint32_t *buffer, size_t size); TEST_DEFINE(GC_FLAGS, 0 ) \ TEST_DEFINE(GC_STEPS, 0 ) \ TEST_DEFINE(GC_COMPACT_THRESH, 0 ) \ - TEST_DEFINE(INLINE_SIZE, BLOCK_SIZE/4 ) \ - TEST_DEFINE(SHRUB_SIZE, INLINE_SIZE ) \ + TEST_DEFINE(SHRUB_SIZE, BLOCK_SIZE/4 ) \ TEST_DEFINE(FRAGMENT_SIZE, BLOCK_SIZE/8 ) \ TEST_DEFINE(CRYSTAL_THRESH, BLOCK_SIZE/8 ) \ TEST_DEFINE(ERASE_VALUE, 0xff ) \ @@ -138,7 +137,6 @@ void test_permutation(size_t i, uint32_t *buffer, size_t size); .lookahead_size = LOOKAHEAD_SIZE, \ TEST_GC_CFG \ .gc_compact_thresh = GC_COMPACT_THRESH, \ - .inline_size = INLINE_SIZE, \ .shrub_size = SHRUB_SIZE, \ .fragment_size = FRAGMENT_SIZE, \ .crystal_thresh = CRYSTAL_THRESH diff --git a/tests/test_ck.toml b/tests/test_ck.toml index 777d9337..f120429d 100644 --- a/tests/test_ck.toml +++ b/tests/test_ck.toml @@ -1657,7 +1657,7 @@ code = ''' defines.BADBIT = -1 defines.BADBLOCK_BEHAVIOR = 'LFS_EMUBD_BADBLOCK_PROGFLIP' # force the file to create a btree -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = '2*FRAGMENT_SIZE' @@ -1956,7 +1956,7 @@ code = ''' [cases.test_ck_ckfetches_btree] defines.BADBIT = -1 # force the file to create a btree -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = '2*FRAGMENT_SIZE' @@ -2213,7 +2213,7 @@ defines.BADBLOCK_BEHAVIOR = [ 'LFS_EMUBD_BADBLOCK_READFLIP', ] # force the file to create a btree -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = '2*FRAGMENT_SIZE' diff --git a/tests/test_fwrite.toml b/tests/test_fwrite.toml index 29b0dba6..3fe21dfe 100644 --- a/tests/test_fwrite.toml +++ b/tests/test_fwrite.toml @@ -103,7 +103,7 @@ code = ''' defines.N = [0, 1, 2, 3, 4] defines.SIZE = 'N*FRAGMENT_SIZE' # force a btree node -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.SYNC = [false, true] in = 'lfs.c' @@ -487,7 +487,7 @@ defines.N = [0, 1, 2, 3, 4] defines.SIZE = 'N*FRAGMENT_SIZE' defines.CHUNK = [32, 8, 1] # force a btree node -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.SYNC = [false, true] defines.REMOUNT = [false, true] diff --git a/tests/test_powerloss.toml b/tests/test_powerloss.toml index 0dd53d16..c1fdded4 100644 --- a/tests/test_powerloss.toml +++ b/tests/test_powerloss.toml @@ -128,7 +128,7 @@ defines.POWERLOSS_BEHAVIOR = [ ] defines.MKCONSISTENT = [false, true] # inlining has a tendency to hide sync issues, so try without -defines.INLINE_SIZE = ['BLOCK_SIZE/4', '0'] +defines.SHRUB_SIZE = ['BLOCK_SIZE/4', '0'] defines.N = [1, 2, 4, 8, 16, 32, 64] defines.SIZE = [ '0', @@ -228,7 +228,7 @@ defines.POWERLOSS_BEHAVIOR = [ ] defines.MKCONSISTENT = [false, true] # inlining has a tendency to hide sync issues, so try without -defines.INLINE_SIZE = ['BLOCK_SIZE/4', '0'] +defines.SHRUB_SIZE = ['BLOCK_SIZE/4', '0'] defines.N = [1, 2, 4, 8, 16, 32, 64] defines.OPS = 256 defines.SIZE = [ @@ -458,7 +458,7 @@ defines.POWERLOSS_BEHAVIOR = [ ] defines.MKCONSISTENT = [false, true] # inlining has a tendency to hide sync issues, so try without -defines.INLINE_SIZE = ['BLOCK_SIZE/4', '0'] +defines.SHRUB_SIZE = ['BLOCK_SIZE/4', '0'] # note dirs x files grows O(n^2) defines.N = [1, 2, 4, 8] defines.M = 'N' diff --git a/tests/test_traversal.toml b/tests/test_traversal.toml index 0b7d5c0e..b0e20d1f 100644 --- a/tests/test_traversal.toml +++ b/tests/test_traversal.toml @@ -2286,7 +2286,7 @@ defines.LOOKAHEAD = [false, true] defines.CKMETA = [false, true] defines.CKDATA = [false, true] defines.SIZE = '2*BLOCK_SIZE' -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.TRUNC = [false, true] code = ''' lfs_t lfs; @@ -2569,7 +2569,7 @@ defines.LOOKAHEAD = [false, true] defines.CKMETA = [false, true] defines.CKDATA = [false, true] defines.SIZE = '2*BLOCK_SIZE' -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 code = ''' lfs_t lfs; lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0; @@ -2858,7 +2858,7 @@ defines.LOOKAHEAD = [false, true] defines.CKMETA = [false, true] defines.CKDATA = [false, true] defines.SIZE = '2*BLOCK_SIZE' -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.DESYNC = [false, true] code = ''' lfs_t lfs; @@ -6652,7 +6652,7 @@ defines.LOOKAHEAD = [false, true] defines.CKMETA = [false, true] defines.CKDATA = [false, true] # limit files to very simple btrees -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = '2*FRAGMENT_SIZE' @@ -6812,7 +6812,7 @@ defines.LOOKAHEAD = [false, true] defines.CKMETA = [false, true] defines.CKDATA = [false, true] # limit files to very simple btrees -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = '2*FRAGMENT_SIZE' @@ -6971,7 +6971,7 @@ defines.CKMETA = [false, true] defines.CKDATA = [false, true] # this configuration should create a 2-layer bshrub, which may be # a bit delicate -defines.INLINE_SIZE = 'BLOCK_SIZE/4' +defines.SHRUB_SIZE = 'BLOCK_SIZE/4' defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = 'BLOCK_SIZE' @@ -7140,7 +7140,7 @@ defines.CKMETA = [false, true] defines.CKDATA = [false, true] # this configuration should create a 2-layer bshrub, which may be # a bit delicate -defines.INLINE_SIZE = 'BLOCK_SIZE/4' +defines.SHRUB_SIZE = 'BLOCK_SIZE/4' defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = 'BLOCK_SIZE'