t: Dropped mtinfo/btinfo, just use data/bptr for everything

It's probably a bad reason, but this avoids wasting too much time
figuring out how to name things.

Now most traversal functions return an lfsr_tag_t + lfsr_bptr_t pair,
which is enough to describe the current relevant traversal objects:

  tag=LFSR_TAG_MDIR   => (lfsr_mdir_t*)bptr.data.u.buffer
  tag=LFSR_TAG_BRANCH => (lfsr_rbyd_t*)bptr.data.u.buffer
  tag=LFSR_TAG_DATA   => bptr.data
  tag=LFSR_TAG_BPTR   => bptr

This would be a bit better if lfsr_data_t's buffer field was a void*,
but that would mess with byte-level arithmetic, which is more common
with lfsr_data_ts.

This also adopts the fragmented/optional out-params used elsewhere in
the codebase. I thought this would add quite a bit more stack cost,
since we need redundant tags/bptrs to make lfsr_mtree_traverse/
lfsr_mtree_gc work, but surprisingly not:

           code          stack
  before: 35256           2680
  after:  35228 (-0.1%)   2680 (+0.0%)

It seems we make up the extra stack cost of redundant tags/bptrs by
giving the compiler more stack-alloc flexibility, tighter per-function
return types, and opting-out of tags/bptrs in most low-level traversals:
lfs_alloc mainly.

But if the fragmented/optional out-params is net harmful for code/stack
size, we should reconsider the pattern system-wide. This does probably
deserve a second look in the future...
This commit is contained in:
Christopher Haster
2024-07-05 14:54:38 -05:00
parent 96834c2460
commit 2e6a5be4e3
6 changed files with 486 additions and 384 deletions
+1 -1
View File
@@ -615,7 +615,7 @@ typedef struct lfsr_dir {
typedef struct lfsr_btraversal {
lfsr_bid_t bid;
lfsr_rbyd_t *branch;
const lfsr_rbyd_t *branch;
lfsr_srid_t rid;
lfsr_rbyd_t rbyd;
} lfsr_btraversal_t;