Use sign bit of rbyd.trunk to indicate shrubness of rbyds
Shrubness should have always been a property of lfsr_rbyd_t.
You know you've made a good design decision when things just sort of
fall into place and the code somehow becomes cleaner.
The downside of this change is accessing rbyd trunks requires a mask,
which is annoying, but the upside is we don't need to signal shrubness
via extra booleans in internal functions anymore.
The funny thing is, the actual motivation for this change is was just to
free up a bit in our tag encoding. Simplifying some of the internal
functions was just a nice side effect.
code stack
before: 33940 2928
after: 33928 (-0.0%) 2912 (-0.5%)
This commit is contained in:
@@ -339,12 +339,15 @@ typedef struct lfs_cache {
|
||||
// TODO do we get ram savings with a lfsr_rorbyd_t substruct? need to measure
|
||||
typedef struct lfsr_rbyd {
|
||||
// note this lines up with weight in lfsr_btree_t
|
||||
// sign(weight)=0 => rbyd
|
||||
lfsr_srid_t weight;
|
||||
lfs_block_t blocks[2];
|
||||
// sign(trunk)=0 => normal rbyd
|
||||
// sign(trunk)=1 => shrub rbyd
|
||||
// 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_ssize_t trunk;
|
||||
lfs_size_t eoff;
|
||||
uint32_t cksum;
|
||||
} lfsr_rbyd_t;
|
||||
@@ -493,7 +496,7 @@ typedef struct lfsr_shrub {
|
||||
// this all lines up with lfsr_rbyd_t
|
||||
lfsr_srid_t weight;
|
||||
lfs_block_t blocks[2];
|
||||
lfs_size_t trunk;
|
||||
lfs_ssize_t trunk;
|
||||
lfs_size_t eoff;
|
||||
// an upper-bound estimate on the on-disk shrub size
|
||||
lfs_size_t estimate;
|
||||
|
||||
Reference in New Issue
Block a user