gc: Moved incremental gc behind ifdef LFS_GC
Incremental gc, being stateful and not gc-able (ironic), was always
going to need to be conditionally compilable.
This moves incremental gc behind the LFS_GC define, so that we can focus
on the "default" costs. This cuts lfs_t in nearly half!
lfs_t with LFS_GC: 308
lfs_t without LFS_C: 168 (-45.5%)
This does save less code than one might expect though. We still need
most of the internal traversal/gc logic for things like block allocation
and orphan cleanup, so most of the savings is limited to the RAM storing
the incremental state:
code stack ctx
before: 37916 2608 768
after with LFS_CFG: 37944 (+0.1%) 2608 (+0.0%) 768 (+0.0%)
after without LFS_CFG: 37796 (-0.3%) 2608 (+0.0%) 620 (-19.3%)
On the flip side, this does mean most of the incremental gc
functionality is still availables in the lfsr_traversal_t APIs.
Applications with more advanced gc use-cases may actually benefit from
_not_ enabling the incremental gc APIs, and instead use the
lfsr_traversal_t APIs directly.
This commit is contained in:
@@ -493,6 +493,7 @@ defines.COMPACT = [false, true]
|
||||
defines.GC_FLAGS = 'LFS_GC_COMPACT'
|
||||
defines.GC_STEPS = -1
|
||||
defines.GC_COMPACT_THRESH = 'BLOCK_SIZE/2'
|
||||
if = 'LFS_IFDEF_GC(true, !COMPACT)'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
@@ -528,9 +529,11 @@ code = '''
|
||||
}
|
||||
|
||||
// try compacting?
|
||||
#ifdef LFS_GC
|
||||
if (COMPACT) {
|
||||
lfsr_gc(&lfs) => 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int remount = 0; remount < 2; remount++) {
|
||||
// remount?
|
||||
@@ -572,6 +575,7 @@ defines.COMPACT = [false, true]
|
||||
defines.GC_FLAGS = 'LFS_GC_COMPACT'
|
||||
defines.GC_STEPS = -1
|
||||
defines.GC_COMPACT_THRESH = 'BLOCK_SIZE/2'
|
||||
if = 'LFS_IFDEF_GC(true, !COMPACT)'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
@@ -608,9 +612,11 @@ code = '''
|
||||
}
|
||||
|
||||
// try compacting?
|
||||
#ifdef LFS_GC
|
||||
if (COMPACT) {
|
||||
lfsr_gc(&lfs) => 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int remount = 0; remount < 2; remount++) {
|
||||
// remount?
|
||||
@@ -4074,6 +4080,7 @@ defines.COMPACT = [false, true]
|
||||
defines.GC_FLAGS = 'LFS_GC_COMPACT'
|
||||
defines.GC_STEPS = -1
|
||||
defines.GC_COMPACT_THRESH = 'BLOCK_SIZE/2'
|
||||
if = 'LFS_IFDEF_GC(true, !COMPACT)'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
@@ -4110,9 +4117,11 @@ code = '''
|
||||
}
|
||||
|
||||
// try compacting?
|
||||
#ifdef LFS_GC
|
||||
if (COMPACT) {
|
||||
lfsr_gc(&lfs) => 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int remount = 0; remount < 2; remount++) {
|
||||
// remount?
|
||||
|
||||
Reference in New Issue
Block a user