Dropped shrub struct, shoved shrub.estimate into shrub.eoff
We still have an lfsr_shrub_t, it's just a simple alias of lfsr_rbyd_t.
The only difference between these two structs was that lfsr_rbyd_t had
the eoff/cksum fields, to enable incremental commits, and lfsr_shrub_t
had the estimate field, to keep track of the current shrub estimate so
we evict before overflow.
Unfortunately C makes this overlap a bit annoying. We can either add a
union, making a mess of field accesses, or use probably problematic
casting of structs with common initial sequences.
Instead of dealing with this headache, I'm just going to shove the
shrub estimate into the rbyd's eoff field and ignore the name abuse.
In normal rbyd use, eoff does effectively contain the on-disk size of
the rbyd, so it's not too far from its intended use...
This does move our estimate to overlap the eoff field instead of the
cksum field, which means we need to be a bit more careful about setting
erased state for btrees. This adds a small code cost:
code stack
before: 33928 2912
after: 33956 (+0.1%) 2912 (+0.0%)
This commit is contained in:
@@ -489,18 +489,13 @@ typedef struct lfsr_bptr {
|
||||
uint32_t cksum;
|
||||
} lfsr_bptr_t;
|
||||
|
||||
// a shrub is a secondary trunk in an mdir, we really only need
|
||||
// trunk/weight/block, so we sneak our estimate into some
|
||||
// overlapping fields
|
||||
typedef struct lfsr_shrub {
|
||||
// this all lines up with lfsr_rbyd_t
|
||||
lfsr_srid_t weight;
|
||||
lfs_block_t blocks[2];
|
||||
lfs_ssize_t trunk;
|
||||
lfs_size_t eoff;
|
||||
// an upper-bound estimate on the on-disk shrub size
|
||||
lfs_size_t estimate;
|
||||
} lfsr_shrub_t;
|
||||
// a shrub is a secondary trunk in an mdir
|
||||
//
|
||||
// note:
|
||||
// - sign(trunk)=1 => shrub
|
||||
// - we shove our shrub estimate into rbyd.eoff, C makes it too annoying
|
||||
// to union another field
|
||||
typedef lfsr_rbyd_t lfsr_shrub_t;
|
||||
|
||||
// the lfsr_bshrub_t struct represents the on-disk component of a file
|
||||
typedef struct lfsr_bshrub {
|
||||
|
||||
Reference in New Issue
Block a user