Moved redundant blocks into the lfsr_rbyd_t struct
This simplifies dependent structs with redundancy, mainly lfsr_mdir_t,
at a significant RAM cost:
code stack structs
before: 30976 2496 1072
after: 30948 (-0.1%) 2528 (+1.3%) 1100 (+2.6%)
Which, to be honest, is not as bad as I thought it would be. Though it
is still pretty bad for no new features.
The motivation for this change:
1. The organization of the previous lfsr_mdir_t struct was a bit hacky
and relied on exact padding so the redund block array and rbyd block
lined up at the right offset.
2. The previous organization prevented theoretical "read-only rbyd
structs" that could omit write-related fields, e.g. eoff and cksum.
This idea is currently unused.
3. The current mdir=level-1, btree/data=level-0 redund design makes this
RAM tradeoff pretty bad, but in theory higher btree redund levels
would need the extra redund blocks in the rbyd struct anyways.
Still, the RAM impact to the current default configuration means this
should probably be reverted...
This commit is contained in:
@@ -363,14 +363,13 @@ typedef struct lfs_cache {
|
||||
typedef struct lfsr_rbyd {
|
||||
// note this lines up with weight in lfsr_btree_t
|
||||
lfsr_srid_t weight;
|
||||
lfs_block_t blocks[2];
|
||||
// eoff=0, trunk=0 => not yet committed
|
||||
// eoff=0, trunk>0 => not yet fetched
|
||||
// eoff>=block_size => rbyd not erased/needs compaction
|
||||
lfs_size_t trunk;
|
||||
lfs_size_t eoff;
|
||||
uint32_t cksum;
|
||||
// note this lines up with arrays of redundant blocks in lfsr_mdir_t
|
||||
lfs_block_t block;
|
||||
} lfsr_rbyd_t;
|
||||
|
||||
typedef struct lfsr_bptr {
|
||||
@@ -389,18 +388,7 @@ typedef struct lfsr_mptr {
|
||||
|
||||
typedef struct lfsr_mdir {
|
||||
lfsr_smid_t mid;
|
||||
union {
|
||||
// here we make sure to line up our block array so it overlaps with
|
||||
// the block stored as the first entry in the rbyd
|
||||
struct {
|
||||
lfsr_srid_t weight;
|
||||
lfs_off_t trunk;
|
||||
lfs_off_t eoff;
|
||||
uint32_t cksum;
|
||||
lfs_block_t blocks[2];
|
||||
} mdir;
|
||||
lfsr_rbyd_t rbyd;
|
||||
} u;
|
||||
lfsr_rbyd_t rbyd;
|
||||
} lfsr_mdir_t;
|
||||
|
||||
typedef struct lfsr_openedmdir {
|
||||
|
||||
Reference in New Issue
Block a user