t: Allow root mutation during bshrub traversals

This adds an indirect pointer to lfsr_btraversal_t, so references to the
btree/bshrub root point to the actual btree/bshrub root rbyd struct.
This means if our bshrub root is mutated due to, say, mdir compaction,
this doesn't necessarily invalidate our btraversal.

But note this is strictly limited to bshrub roots. If you modify any
other part of the bshrub/btree, expect the traversal to be broken.

This means we can do whatever we want with mdirs and not worry about
invaliding bshrub traversals, which is quite nice! It also fixes our
failing bshrub-traversal-mutation tests.

This adds a bit of stack cost, but because we are moving fewer rbyd
structs around in lfsr_btree_traverse_, actually ends up saving a bit of
code. Though we are well below the compiler noise floor:

           code          stack
  before: 35368           2680
  after:  35356 (-0.0%)   2688 (+0.3%)
This commit is contained in:
Christopher Haster
2024-07-02 19:29:17 -05:00
parent 7fdf0b7d23
commit 7b8667d7df
2 changed files with 26 additions and 23 deletions
+2 -1
View File
@@ -608,8 +608,9 @@ typedef struct lfsr_dir {
typedef struct lfsr_btraversal {
lfsr_bid_t bid;
const lfsr_rbyd_t *branch;
lfsr_srid_t rid;
lfsr_rbyd_t branch;
lfsr_rbyd_t rbyd;
} lfsr_btraversal_t;
typedef struct lfsr_mtraversal {