Changed mtree to be weighted by mdir upper bound
More on this when explaining compressed mids, but basically the idea is instead of just storing all mdirs in our mtree as single element entries, store each mdir in as a weighted entry, where the weight is a known upper bound on the possible number of mid entries in a single mdir. With the current mid representation, this just complicates things without much benefits. But with compressed mids it allows us to lookup mdirs with the mid directly, and avoid decoding the bid from the mid in some cases. The mid-per-mdir upper bound is derived from the block size. We know: 1. Each tag needs <=2 alts+null with our current compaction strategy 2. Each tag/alt encodes to a minimum of 4 bytes This gives us ~4*4 or ~16 bytes per mid at minimum. If we cram an mdir with the smallest possible mids, this gives us at most ~block_size/16 mids in a single mdir before the mdir runs out of space. Note we can't assume ~1/2 block utilization here, as an mdir may temporarily fill with more mids before compaction occurs.
This commit is contained in:
@@ -517,13 +517,14 @@ typedef struct lfs {
|
||||
lfs_size_t attr_max;
|
||||
|
||||
// begin lfsr things
|
||||
lfsr_mdir_t mroot;
|
||||
lfsr_btree_t mtree;
|
||||
|
||||
lfsr_grm_t grm;
|
||||
uint8_t pgrm[LFSR_GRM_DSIZE];
|
||||
uint8_t dgrm[LFSR_GRM_DSIZE];
|
||||
|
||||
uint8_t mrid_bits;
|
||||
lfsr_mdir_t mroot;
|
||||
lfsr_btree_t mtree;
|
||||
|
||||
// linked-lists of opened mdirs, we keep a separate linked-list
|
||||
// for each type since these need to be handled a bit differently
|
||||
lfsr_openedmdir_t *opened[2];
|
||||
|
||||
Reference in New Issue
Block a user