t: Changed mtinfo/btinfo to refer to mdirs/rbyds by pointer

This solves the issue of multiple mdirs/rbyds in lfsr_mtree_gc, where
it's easy for traversal state to fall out of sync when mutating parts of
the filesystem.

Is it good design, with self-referential pointers making everything more
entangled? Not sure!

This saves a bit of stack, but adds a bit of code, which makes sense,
pointer chasing can be costly. But both of these changes are well below
the compiler noise floor:

           code          stack
  before: 35228           2688
  after:  35256 (+0.1%)   2680 (-0.3%)
This commit is contained in:
Christopher Haster
2024-07-04 02:10:40 -05:00
parent bfc108c1dc
commit 3c7b462659
5 changed files with 152 additions and 155 deletions
+27 -27
View File
@@ -179,23 +179,23 @@ code = '''
if (mtinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
mtinfo.tag,
mtinfo.u.mdir.rbyd.blocks[0],
mtinfo.u.mdir.rbyd.blocks[1]);
mtinfo.u.mdir->rbyd.blocks[0],
mtinfo.u.mdir->rbyd.blocks[1]);
// keep track of seen blocks
seen[mtinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (mtinfo.u.mdir.rbyd.blocks[1] % 8);
seen[mtinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (mtinfo.u.mdir.rbyd.blocks[0] % 8);
seen[mtinfo.u.mdir->rbyd.blocks[1] / 8]
|= 1 << (mtinfo.u.mdir->rbyd.blocks[1] % 8);
seen[mtinfo.u.mdir->rbyd.blocks[0] / 8]
|= 1 << (mtinfo.u.mdir->rbyd.blocks[0] % 8);
} else if (mtinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
mtinfo.tag,
mtinfo.u.rbyd.blocks[0], mtinfo.u.rbyd.trunk);
mtinfo.u.rbyd->blocks[0], mtinfo.u.rbyd->trunk);
// keep track of seen blocks
seen[mtinfo.u.rbyd.blocks[0] / 8]
|= 1 << (mtinfo.u.rbyd.blocks[0] % 8);
seen[mtinfo.u.rbyd->blocks[0] / 8]
|= 1 << (mtinfo.u.rbyd->blocks[0] % 8);
} else {
// this shouldn't happen
@@ -347,23 +347,23 @@ code = '''
if (mtinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
mtinfo.tag,
mtinfo.u.mdir.rbyd.blocks[0],
mtinfo.u.mdir.rbyd.blocks[1]);
mtinfo.u.mdir->rbyd.blocks[0],
mtinfo.u.mdir->rbyd.blocks[1]);
// keep track of seen blocks
seen[mtinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (mtinfo.u.mdir.rbyd.blocks[1] % 8);
seen[mtinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (mtinfo.u.mdir.rbyd.blocks[0] % 8);
seen[mtinfo.u.mdir->rbyd.blocks[1] / 8]
|= 1 << (mtinfo.u.mdir->rbyd.blocks[1] % 8);
seen[mtinfo.u.mdir->rbyd.blocks[0] / 8]
|= 1 << (mtinfo.u.mdir->rbyd.blocks[0] % 8);
} else if (mtinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
mtinfo.tag,
mtinfo.u.rbyd.blocks[0], mtinfo.u.rbyd.trunk);
mtinfo.u.rbyd->blocks[0], mtinfo.u.rbyd->trunk);
// keep track of seen blocks
seen[mtinfo.u.rbyd.blocks[0] / 8]
|= 1 << (mtinfo.u.rbyd.blocks[0] % 8);
seen[mtinfo.u.rbyd->blocks[0] / 8]
|= 1 << (mtinfo.u.rbyd->blocks[0] % 8);
} else if (mtinfo.tag == LFSR_TAG_BLOCK) {
printf("traversal: 0x%x block 0x%x\n",
@@ -501,23 +501,23 @@ code = '''
if (mtinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
mtinfo.tag,
mtinfo.u.mdir.rbyd.blocks[0],
mtinfo.u.mdir.rbyd.blocks[1]);
mtinfo.u.mdir->rbyd.blocks[0],
mtinfo.u.mdir->rbyd.blocks[1]);
// keep track of seen blocks
seen[mtinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (mtinfo.u.mdir.rbyd.blocks[1] % 8);
seen[mtinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (mtinfo.u.mdir.rbyd.blocks[0] % 8);
seen[mtinfo.u.mdir->rbyd.blocks[1] / 8]
|= 1 << (mtinfo.u.mdir->rbyd.blocks[1] % 8);
seen[mtinfo.u.mdir->rbyd.blocks[0] / 8]
|= 1 << (mtinfo.u.mdir->rbyd.blocks[0] % 8);
} else if (mtinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
mtinfo.tag,
mtinfo.u.rbyd.blocks[0], mtinfo.u.rbyd.trunk);
mtinfo.u.rbyd->blocks[0], mtinfo.u.rbyd->trunk);
// keep track of seen blocks
seen[mtinfo.u.rbyd.blocks[0] / 8]
|= 1 << (mtinfo.u.rbyd.blocks[0] % 8);
seen[mtinfo.u.rbyd->blocks[0] / 8]
|= 1 << (mtinfo.u.rbyd->blocks[0] % 8);
} else if (mtinfo.tag == LFSR_TAG_BLOCK) {
printf("traversal: 0x%x block 0x%x\n",