Adopted scaling of did hashes based on the number of metadata entries

Instead of truncating to exactly 28-bits for nice leb128 alignment, we
now truncate to ~the number of metadata entries, which must be >= ~2x
the number dids since each did needs a dir entry and dstart entry.

This has the downside of needing to actually keep track of an estimate
of the number of metadata entries, which is made a bit difficult due to
integer overflow issues (we can have more than 2^32 metadata entries),
but has the upside of allowing a full 2^32 number of dids worst case.
This is really unlikely, but it's nice to not need another configuration
option to control the did limit.

Another option would be to scale the hashes based on the number dids,
which would be a more direct solution. Unfortunately determining the
number of dids during mount requires a O(m*log(m)) scan of each rbyd
to find either dir entries or dstart entries. This solution can easily
end up with an overestimate, but only needs to weight of each rbyd which
can be (and already is) found in O(m).
This commit is contained in:
Christopher Haster
2023-07-19 01:40:02 -05:00
parent c5e84e874f
commit 389987ee4f
2 changed files with 29 additions and 17 deletions
+1
View File
@@ -492,6 +492,7 @@ typedef struct lfs {
// begin lfsr things
lfsr_mdir_t mroot;
lfsr_btree_t mtree;
lfs_size_t mlimit;
// TODO do we really need separate decoded/encoded grms?
lfsr_grm_t grm_;