Compare commits

...

8 Commits

Author SHA1 Message Date
Christopher Haster
ab59ab7f8d Bump default inline_max up to 1/4 block size
As noted by amgross, the current inline_max default (when littlefs
switches from inline files to CTZ skip-lists) does not match the
theoretical value in DESIGN.md.

The reason for this is 1/8 was chosen as a safer default during
development, due to concerns that 1/4 + mdirs splitting at 1/2 would
lead to poor distribution of large inline files in mdirs.

However, two things have happened since then:

1. Experiments have show "wasted" mdir space is less of a concern than
   initially thought. Extra mdir space contributes to logging, delays
   mdir compaction, and can overall lead to better performance.

2. inline_size was added as a configuration option, so if 1/4 is
   problematic users can always override it.

So bumping this back up to 1/4 may make sense.
2025-09-30 12:15:26 -05:00
Christopher Haster
8e251dd675 Merge pull request #1110 from Ryan-CW-Code/perf_gc
perf: gc might try to populate the lookahead buffer each time
2025-06-30 11:39:17 -05:00
Christopher Haster
25b9a4af85 Merge pull request #1109 from Ryan-CW-Code/never_read
refactor: value stored to 'diff' is never read
2025-06-30 11:39:05 -05:00
Christopher Haster
2acf939a00 Merge pull request #1106 from littlefs-project/fix-make-build-dep
make: Add missing BUILD_DEP include
2025-06-30 11:38:56 -05:00
ryancw
d5a86fd28d style: format code, limit to 80 columns. 2025-06-03 09:46:59 +08:00
ryancw
2349ac8c96 perf: gc might try to populate the lookahead buffer each time 2025-05-28 10:23:47 +08:00
ryancw
0755b00c21 refactor: value stored to 'diff' is never read 2025-05-27 20:00:29 +08:00
Christopher Haster
8365bbb7a2 make: Added missing BUILD_DEP include
This was preventing bench modifications from triggering relevant
bench-runner rebuilds.
2025-05-15 13:38:31 -05:00
3 changed files with 7 additions and 7 deletions

View File

@@ -475,6 +475,7 @@ benchmarks-diff: $(BENCH_CSV)
# rules
-include $(DEP)
-include $(TEST_DEP)
-include $(BENCH_DEP)
.SUFFIXES:
.SECONDARY:

11
lfs.c
View File

@@ -828,9 +828,6 @@ static int lfs_dir_getread(lfs_t *lfs, const lfs_mdir_t *dir,
size -= diff;
continue;
}
// rcache takes priority
diff = lfs_min(diff, rcache->off-off);
}
// load to cache, first condition can no longer fail
@@ -4334,7 +4331,7 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
LFS_ASSERT(lfs->cfg->inline_max == (lfs_size_t)-1
|| lfs->cfg->inline_max <= ((lfs->cfg->metadata_max)
? lfs->cfg->metadata_max
: lfs->cfg->block_size)/8);
: lfs->cfg->block_size)/4);
lfs->inline_max = lfs->cfg->inline_max;
if (lfs->inline_max == (lfs_size_t)-1) {
lfs->inline_max = 0;
@@ -4345,7 +4342,7 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
lfs->attr_max,
((lfs->cfg->metadata_max)
? lfs->cfg->metadata_max
: lfs->cfg->block_size)/8));
: lfs->cfg->block_size)/4));
}
// setup default state
@@ -5225,7 +5222,9 @@ static int lfs_fs_gc_(lfs_t *lfs) {
}
// try to populate the lookahead buffer, unless it's already full
if (lfs->lookahead.size < 8*lfs->cfg->lookahead_size) {
if (lfs->lookahead.size < lfs_min(
8 * lfs->cfg->lookahead_size,
lfs->block_count)) {
err = lfs_alloc_scan(lfs);
if (err) {
return err;

2
lfs.h
View File

@@ -277,7 +277,7 @@ struct lfs_config {
// Optional upper limit on inlined files in bytes. Inlined files live in
// metadata and decrease storage requirements, but may be limited to
// improve metadata-related performance. Must be <= cache_size, <=
// attr_max, and <= block_size/8. Defaults to the largest possible
// attr_max, and <= block_size/4. Defaults to the largest possible
// inline_max when zero.
//
// Set to -1 to disable inlined files.