Rerouted all btree mutation through attr-list parser
The idea here: Instead of having unique functionality for each individual btree operation (push/set/pop/split), we treat btrees sort of like rbyds, with a single commit entry point that operates on attr-lists. This adds code cost, due to needing to parse the attr-list for properties that can affect inlined btrees (tag changes mostly), but, in theory, comes with some advantages: 1. A single btree commit entry point with all of the inlined/uninlining logic should offer better chances for code deduplication, vs spreading this logic out in each btree operation. 2. Higher-levels should know what the current weight of the branch is, so we may be able to avoid the implicit math needed to calculate deltas. 3. Higher-levels have more knowledge about the state of the btree in general, so there may be other shortcuts. The mtree, for example, only operates on weight=1 entries, which greatly simplifies a lot of the related math. Note that btrees still have strict limits in what's possible in an attr-list. Btree operations can't cross leaf-rbyd boundaries for example. --- A notable omission in this change is the loss of reinlining btrees. This wase dropped for a couple reasons. It may be worth adding back at a later time, maybe after we actually have files implemented, but for now does not seem worth it: 1. Reinlining adds code cost. Reinlining is more complex than you might expect because we only reinline on compaction. And because we compact before playing out our attr-list, we need to know if a commit makes the btree inlinable before committing to the btree. This is still doable with our attr-lists. We already derive the change in tags, since we need this to know when to uninline. But it adds a kind of complex bailing out of btree commits. 2. The benefits of reinlining may not be that great. In most systems, a tree that is uninlined once is likely to be uninlined again. It's only if there is a bigger state change in a system that it makes sense to reinline. Though, to be fair, waiting for compaction to reinline handled this quite well. Only reinlining when all erased storage is used up... 3. Thanks to our roots did entry, our mtree can never reinline. It would be nice to change this, but this would require explicit handling in lfsr_mdir_commit. Future work? 4. Files are another can of worms, with more complex interactions with inlinability thanks to (at least on paper right now) always having inlined data even when uninlined. If reinlining is valuable for files this can change during that work. 5. Even if files never support reinlinability, truncating files (via either lfsr_file_truncate or LFSR_O_TRUNC) should give the file a blank slate, effectively reinlining the file in that case. --- The current implementation also changes the attr-list to be mutable so we can adjust attr-list based on the current btree node. This is a temporary hack! We should add the appropriate functionality to our rbyd utilities to revert this eventually.
This commit is contained in:
+257
-257
@@ -2424,263 +2424,263 @@ code = '''
|
||||
free(sim);
|
||||
'''
|
||||
|
||||
|
||||
# test we reinline (go from uninlined to inlined) correctly, this is a bit
|
||||
# tricky since our btrees lazily reinline
|
||||
[cases.test_btree_reinline_pop_set]
|
||||
in = 'lfs.c'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfs_init(&lfs, CFG) => 0;
|
||||
// create free lookahead
|
||||
memset(lfs.lookahead.buffer, 0, CFG->lookahead_size);
|
||||
lfs.lookahead.start = 0;
|
||||
lfs.lookahead.size = lfs_min(8*CFG->lookahead_size,
|
||||
CFG->block_count);
|
||||
lfs.lookahead.next = 0;
|
||||
lfs_alloc_ack(&lfs);
|
||||
|
||||
// create an uninlined tree
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL;
|
||||
lfsr_btree_push(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
LFSR_DATA("a", 1)) => 0;
|
||||
lfsr_btree_push(&lfs, &btree, 1, LFSR_TAG_INLINED, 1,
|
||||
LFSR_DATA("b", 1)) => 0;
|
||||
assert(lfsr_btree_weight(&btree) == 2);
|
||||
assert(!lfsr_btree_isinlined(&btree));
|
||||
|
||||
// pop! our btree should now be reinlinable
|
||||
lfsr_btree_pop(&lfs, &btree, 0) => 0;
|
||||
|
||||
// but thanks to lazy reinlining, our btree won't reinline until
|
||||
// it is compacted, so we need to add commits until it is compacted
|
||||
lfs_block_t before_block = btree.u.r.rbyd.block;
|
||||
for (lfs_block_t i = 0;; i++) {
|
||||
// a bit hacky, but this catches infinite loops
|
||||
assert(i < BLOCK_SIZE);
|
||||
|
||||
// commit to btree
|
||||
lfsr_btree_set(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
LFSR_DATA("b", 1)) => 0;
|
||||
|
||||
assert(lfsr_btree_weight(&btree) == 1);
|
||||
|
||||
// try looking up tag to hopefully catch if something breaks
|
||||
uint8_t buffer[4];
|
||||
lfsr_tag_t tag_;
|
||||
lfs_size_t weight_;
|
||||
|
||||
lfsr_btree_get(&lfs, &btree, 0,
|
||||
&tag_, &weight_, buffer, 4) => 1;
|
||||
assert(tag_ == LFSR_TAG_INLINED);
|
||||
assert(weight_ == 1);
|
||||
assert(memcmp(buffer, "b", 1) == 0);
|
||||
|
||||
// inlined? consider this a success
|
||||
if (lfsr_btree_isinlined(&btree)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// assert if a compaction occurred that wasn't inlined
|
||||
assert(btree.u.r.rbyd.block == before_block);
|
||||
}
|
||||
|
||||
printf("btree: w%d 0x%x.%x\n",
|
||||
btree.u.r.rbyd.weight,
|
||||
btree.u.r.rbyd.block,
|
||||
btree.u.r.rbyd.trunk);
|
||||
'''
|
||||
|
||||
[cases.test_btree_reinline_pop_pop_push]
|
||||
in = 'lfs.c'
|
||||
defines.SHIFT = 'range(5)'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfs_init(&lfs, CFG) => 0;
|
||||
// create free lookahead
|
||||
memset(lfs.lookahead.buffer, 0, CFG->lookahead_size);
|
||||
lfs.lookahead.start = 0;
|
||||
lfs.lookahead.size = lfs_min(8*CFG->lookahead_size,
|
||||
CFG->block_count);
|
||||
lfs.lookahead.next = 0;
|
||||
lfs_alloc_ack(&lfs);
|
||||
|
||||
// create an uninlined tree
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL;
|
||||
lfsr_btree_push(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
LFSR_DATA("a", 1)) => 0;
|
||||
lfsr_btree_push(&lfs, &btree, 1, LFSR_TAG_INLINED, 1,
|
||||
LFSR_DATA("b", 1)) => 0;
|
||||
assert(lfsr_btree_weight(&btree) == 2);
|
||||
assert(!lfsr_btree_isinlined(&btree));
|
||||
|
||||
// pop! our btree should now be reinlinable
|
||||
lfsr_btree_pop(&lfs, &btree, 0) => 0;
|
||||
|
||||
// It's difficult to test reinlining during push or pop, since we can't just
|
||||
// repeat the action until compaction occurs.
|
||||
//
|
||||
// What we do here is alternate between 0 and 1 entries, eventually we
|
||||
// will compact during one of either a push or pop. To try to cover both,
|
||||
// test with some number of extra commits to hopefully adjust where the
|
||||
// compaction ends up.
|
||||
for (lfs_size_t i = 0; i < SHIFT; i++) {
|
||||
lfsr_btree_set(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
LFSR_DATA("b", 1)) => 0;
|
||||
}
|
||||
|
||||
// alternate between push/pop until compaction occurs
|
||||
lfs_block_t before_block = btree.u.r.rbyd.block;
|
||||
for (lfs_block_t i = 0;; i++) {
|
||||
// a bit hacky, but this catches infinite loops
|
||||
assert(i < BLOCK_SIZE);
|
||||
|
||||
// pop!
|
||||
lfsr_btree_pop(&lfs, &btree, 0) => 0;
|
||||
|
||||
assert(lfsr_btree_weight(&btree) == 0);
|
||||
|
||||
// inlined? consider this a success
|
||||
if (lfsr_btree_isinlined(&btree)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// assert if a compaction occurred that wasn't inlined
|
||||
assert(btree.u.r.rbyd.block == before_block);
|
||||
|
||||
// push!
|
||||
lfsr_btree_push(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
LFSR_DATA("c", 1)) => 0;
|
||||
|
||||
// try looking up tag to hopefully catch if something breaks
|
||||
uint8_t buffer[4];
|
||||
lfsr_tag_t tag_;
|
||||
lfs_size_t weight_;
|
||||
|
||||
lfsr_btree_get(&lfs, &btree, 0,
|
||||
&tag_, &weight_, buffer, 4) => 1;
|
||||
assert(tag_ == LFSR_TAG_INLINED);
|
||||
assert(weight_ == 1);
|
||||
assert(memcmp(buffer, "c", 1) == 0);
|
||||
|
||||
// inlined? consider this a success
|
||||
if (lfsr_btree_isinlined(&btree)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// assert if a compaction occurred that wasn't inlined
|
||||
assert(btree.u.r.rbyd.block == before_block);
|
||||
}
|
||||
|
||||
printf("btree: w%d 0x%x.%x\n",
|
||||
btree.u.r.rbyd.weight,
|
||||
btree.u.r.rbyd.block,
|
||||
btree.u.r.rbyd.trunk);
|
||||
'''
|
||||
|
||||
[cases.test_btree_reinline_pop_push]
|
||||
in = 'lfs.c'
|
||||
defines.SIBLING = [0, 1]
|
||||
defines.SHIFT = 'range(5)'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfs_init(&lfs, CFG) => 0;
|
||||
// create free lookahead
|
||||
memset(lfs.lookahead.buffer, 0, CFG->lookahead_size);
|
||||
lfs.lookahead.start = 0;
|
||||
lfs.lookahead.size = lfs_min(8*CFG->lookahead_size,
|
||||
CFG->block_count);
|
||||
lfs.lookahead.next = 0;
|
||||
lfs_alloc_ack(&lfs);
|
||||
|
||||
// create an uninlined tree
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL;
|
||||
lfsr_btree_push(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
LFSR_DATA("a", 1)) => 0;
|
||||
lfsr_btree_push(&lfs, &btree, 1, LFSR_TAG_INLINED, 1,
|
||||
LFSR_DATA("b", 1)) => 0;
|
||||
assert(lfsr_btree_weight(&btree) == 2);
|
||||
assert(!lfsr_btree_isinlined(&btree));
|
||||
|
||||
// It's difficult to test reinlining during push or pop, since we can't just
|
||||
// repeat the action until compaction occurs.
|
||||
//
|
||||
// Here we alternate between 1 and 2 entries, with the hope that compaction
|
||||
// occurs on the pop. We try this with some number of extra commits to make
|
||||
// it more likely pop is tested.
|
||||
//
|
||||
// It's possible our commits line up so compaction always occurs on a push!
|
||||
// For this reason, we end the test if an non-reinlining compaction occurs.
|
||||
for (lfs_size_t i = 0; i < SHIFT; i++) {
|
||||
lfsr_btree_set(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
LFSR_DATA("a", 1)) => 0;
|
||||
}
|
||||
|
||||
// alternate between push/pop until compaction occurs
|
||||
lfs_block_t before_block = btree.u.r.rbyd.block;
|
||||
for (lfs_block_t i = 0;; i++) {
|
||||
// a bit hacky, but this catches infinite loops
|
||||
assert(i < BLOCK_SIZE);
|
||||
|
||||
// pop!
|
||||
lfsr_btree_pop(&lfs, &btree, SIBLING) => 0;
|
||||
|
||||
assert(lfsr_btree_weight(&btree) == 1);
|
||||
|
||||
// try looking up tag to hopefully catch if something breaks
|
||||
uint8_t buffer[4];
|
||||
lfsr_tag_t tag_;
|
||||
lfs_size_t weight_;
|
||||
|
||||
lfsr_btree_get(&lfs, &btree, 0,
|
||||
&tag_, &weight_, buffer, 4) => 1;
|
||||
assert(tag_ == LFSR_TAG_INLINED);
|
||||
assert(weight_ == 1);
|
||||
assert(memcmp(buffer, (SIBLING == 1 ? "a" : "b"), 1) == 0);
|
||||
|
||||
// inlined? consider this a success
|
||||
if (lfsr_btree_isinlined(&btree)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// abort if a compaction occurs
|
||||
if (btree.u.r.rbyd.block != before_block) {
|
||||
break;
|
||||
}
|
||||
|
||||
// push!
|
||||
lfsr_btree_push(&lfs, &btree, SIBLING, LFSR_TAG_INLINED, 1,
|
||||
LFSR_DATA("c", 1)) => 0;
|
||||
|
||||
// try looking up tag to hopefully catch if something breaks
|
||||
lfsr_btree_get(&lfs, &btree, 0,
|
||||
&tag_, &weight_, buffer, 4) => 1;
|
||||
assert(tag_ == LFSR_TAG_INLINED);
|
||||
assert(weight_ == 1);
|
||||
assert(memcmp(buffer, (SIBLING == 1 ? "a" : "c"), 1) == 0);
|
||||
|
||||
lfsr_btree_get(&lfs, &btree, 1,
|
||||
&tag_, &weight_, buffer, 4) => 1;
|
||||
assert(tag_ == LFSR_TAG_INLINED);
|
||||
assert(weight_ == 1);
|
||||
assert(memcmp(buffer, (SIBLING == 1 ? "c" : "b"), 1) == 0);
|
||||
|
||||
// inlined? consider this a success
|
||||
if (lfsr_btree_isinlined(&btree)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// abort if a compaction occurs
|
||||
if (btree.u.r.rbyd.block != before_block) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("btree: w%d 0x%x.%x\n",
|
||||
btree.u.r.rbyd.weight,
|
||||
btree.u.r.rbyd.block,
|
||||
btree.u.r.rbyd.trunk);
|
||||
'''
|
||||
# TODO
|
||||
## test we reinline (go from uninlined to inlined) correctly, this is a bit
|
||||
## tricky since our btrees lazily reinline
|
||||
#[cases.test_btree_reinline_pop_set]
|
||||
#in = 'lfs.c'
|
||||
#code = '''
|
||||
# lfs_t lfs;
|
||||
# lfs_init(&lfs, CFG) => 0;
|
||||
# // create free lookahead
|
||||
# memset(lfs.lookahead.buffer, 0, CFG->lookahead_size);
|
||||
# lfs.lookahead.start = 0;
|
||||
# lfs.lookahead.size = lfs_min(8*CFG->lookahead_size,
|
||||
# CFG->block_count);
|
||||
# lfs.lookahead.next = 0;
|
||||
# lfs_alloc_ack(&lfs);
|
||||
#
|
||||
# // create an uninlined tree
|
||||
# lfsr_btree_t btree = LFSR_BTREE_NULL;
|
||||
# lfsr_btree_push(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
# LFSR_DATA("a", 1)) => 0;
|
||||
# lfsr_btree_push(&lfs, &btree, 1, LFSR_TAG_INLINED, 1,
|
||||
# LFSR_DATA("b", 1)) => 0;
|
||||
# assert(lfsr_btree_weight(&btree) == 2);
|
||||
# assert(!lfsr_btree_isinlined(&btree));
|
||||
#
|
||||
# // pop! our btree should now be reinlinable
|
||||
# lfsr_btree_pop(&lfs, &btree, 0) => 0;
|
||||
#
|
||||
# // but thanks to lazy reinlining, our btree won't reinline until
|
||||
# // it is compacted, so we need to add commits until it is compacted
|
||||
# lfs_block_t before_block = btree.u.r.rbyd.block;
|
||||
# for (lfs_block_t i = 0;; i++) {
|
||||
# // a bit hacky, but this catches infinite loops
|
||||
# assert(i < BLOCK_SIZE);
|
||||
#
|
||||
# // commit to btree
|
||||
# lfsr_btree_set(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
# LFSR_DATA("b", 1)) => 0;
|
||||
#
|
||||
# assert(lfsr_btree_weight(&btree) == 1);
|
||||
#
|
||||
# // try looking up tag to hopefully catch if something breaks
|
||||
# uint8_t buffer[4];
|
||||
# lfsr_tag_t tag_;
|
||||
# lfs_size_t weight_;
|
||||
#
|
||||
# lfsr_btree_get(&lfs, &btree, 0,
|
||||
# &tag_, &weight_, buffer, 4) => 1;
|
||||
# assert(tag_ == LFSR_TAG_INLINED);
|
||||
# assert(weight_ == 1);
|
||||
# assert(memcmp(buffer, "b", 1) == 0);
|
||||
#
|
||||
# // inlined? consider this a success
|
||||
# if (lfsr_btree_isinlined(&btree)) {
|
||||
# break;
|
||||
# }
|
||||
#
|
||||
# // assert if a compaction occurred that wasn't inlined
|
||||
# assert(btree.u.r.rbyd.block == before_block);
|
||||
# }
|
||||
#
|
||||
# printf("btree: w%d 0x%x.%x\n",
|
||||
# btree.u.r.rbyd.weight,
|
||||
# btree.u.r.rbyd.block,
|
||||
# btree.u.r.rbyd.trunk);
|
||||
#'''
|
||||
#
|
||||
#[cases.test_btree_reinline_pop_pop_push]
|
||||
#in = 'lfs.c'
|
||||
#defines.SHIFT = 'range(5)'
|
||||
#code = '''
|
||||
# lfs_t lfs;
|
||||
# lfs_init(&lfs, CFG) => 0;
|
||||
# // create free lookahead
|
||||
# memset(lfs.lookahead.buffer, 0, CFG->lookahead_size);
|
||||
# lfs.lookahead.start = 0;
|
||||
# lfs.lookahead.size = lfs_min(8*CFG->lookahead_size,
|
||||
# CFG->block_count);
|
||||
# lfs.lookahead.next = 0;
|
||||
# lfs_alloc_ack(&lfs);
|
||||
#
|
||||
# // create an uninlined tree
|
||||
# lfsr_btree_t btree = LFSR_BTREE_NULL;
|
||||
# lfsr_btree_push(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
# LFSR_DATA("a", 1)) => 0;
|
||||
# lfsr_btree_push(&lfs, &btree, 1, LFSR_TAG_INLINED, 1,
|
||||
# LFSR_DATA("b", 1)) => 0;
|
||||
# assert(lfsr_btree_weight(&btree) == 2);
|
||||
# assert(!lfsr_btree_isinlined(&btree));
|
||||
#
|
||||
# // pop! our btree should now be reinlinable
|
||||
# lfsr_btree_pop(&lfs, &btree, 0) => 0;
|
||||
#
|
||||
# // It's difficult to test reinlining during push or pop, since we can't just
|
||||
# // repeat the action until compaction occurs.
|
||||
# //
|
||||
# // What we do here is alternate between 0 and 1 entries, eventually we
|
||||
# // will compact during one of either a push or pop. To try to cover both,
|
||||
# // test with some number of extra commits to hopefully adjust where the
|
||||
# // compaction ends up.
|
||||
# for (lfs_size_t i = 0; i < SHIFT; i++) {
|
||||
# lfsr_btree_set(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
# LFSR_DATA("b", 1)) => 0;
|
||||
# }
|
||||
#
|
||||
# // alternate between push/pop until compaction occurs
|
||||
# lfs_block_t before_block = btree.u.r.rbyd.block;
|
||||
# for (lfs_block_t i = 0;; i++) {
|
||||
# // a bit hacky, but this catches infinite loops
|
||||
# assert(i < BLOCK_SIZE);
|
||||
#
|
||||
# // pop!
|
||||
# lfsr_btree_pop(&lfs, &btree, 0) => 0;
|
||||
#
|
||||
# assert(lfsr_btree_weight(&btree) == 0);
|
||||
#
|
||||
# // inlined? consider this a success
|
||||
# if (lfsr_btree_isinlined(&btree)) {
|
||||
# break;
|
||||
# }
|
||||
#
|
||||
# // assert if a compaction occurred that wasn't inlined
|
||||
# assert(btree.u.r.rbyd.block == before_block);
|
||||
#
|
||||
# // push!
|
||||
# lfsr_btree_push(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
# LFSR_DATA("c", 1)) => 0;
|
||||
#
|
||||
# // try looking up tag to hopefully catch if something breaks
|
||||
# uint8_t buffer[4];
|
||||
# lfsr_tag_t tag_;
|
||||
# lfs_size_t weight_;
|
||||
#
|
||||
# lfsr_btree_get(&lfs, &btree, 0,
|
||||
# &tag_, &weight_, buffer, 4) => 1;
|
||||
# assert(tag_ == LFSR_TAG_INLINED);
|
||||
# assert(weight_ == 1);
|
||||
# assert(memcmp(buffer, "c", 1) == 0);
|
||||
#
|
||||
# // inlined? consider this a success
|
||||
# if (lfsr_btree_isinlined(&btree)) {
|
||||
# break;
|
||||
# }
|
||||
#
|
||||
# // assert if a compaction occurred that wasn't inlined
|
||||
# assert(btree.u.r.rbyd.block == before_block);
|
||||
# }
|
||||
#
|
||||
# printf("btree: w%d 0x%x.%x\n",
|
||||
# btree.u.r.rbyd.weight,
|
||||
# btree.u.r.rbyd.block,
|
||||
# btree.u.r.rbyd.trunk);
|
||||
#'''
|
||||
#
|
||||
#[cases.test_btree_reinline_pop_push]
|
||||
#in = 'lfs.c'
|
||||
#defines.SIBLING = [0, 1]
|
||||
#defines.SHIFT = 'range(5)'
|
||||
#code = '''
|
||||
# lfs_t lfs;
|
||||
# lfs_init(&lfs, CFG) => 0;
|
||||
# // create free lookahead
|
||||
# memset(lfs.lookahead.buffer, 0, CFG->lookahead_size);
|
||||
# lfs.lookahead.start = 0;
|
||||
# lfs.lookahead.size = lfs_min(8*CFG->lookahead_size,
|
||||
# CFG->block_count);
|
||||
# lfs.lookahead.next = 0;
|
||||
# lfs_alloc_ack(&lfs);
|
||||
#
|
||||
# // create an uninlined tree
|
||||
# lfsr_btree_t btree = LFSR_BTREE_NULL;
|
||||
# lfsr_btree_push(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
# LFSR_DATA("a", 1)) => 0;
|
||||
# lfsr_btree_push(&lfs, &btree, 1, LFSR_TAG_INLINED, 1,
|
||||
# LFSR_DATA("b", 1)) => 0;
|
||||
# assert(lfsr_btree_weight(&btree) == 2);
|
||||
# assert(!lfsr_btree_isinlined(&btree));
|
||||
#
|
||||
# // It's difficult to test reinlining during push or pop, since we can't just
|
||||
# // repeat the action until compaction occurs.
|
||||
# //
|
||||
# // Here we alternate between 1 and 2 entries, with the hope that compaction
|
||||
# // occurs on the pop. We try this with some number of extra commits to make
|
||||
# // it more likely pop is tested.
|
||||
# //
|
||||
# // It's possible our commits line up so compaction always occurs on a push!
|
||||
# // For this reason, we end the test if an non-reinlining compaction occurs.
|
||||
# for (lfs_size_t i = 0; i < SHIFT; i++) {
|
||||
# lfsr_btree_set(&lfs, &btree, 0, LFSR_TAG_INLINED, 1,
|
||||
# LFSR_DATA("a", 1)) => 0;
|
||||
# }
|
||||
#
|
||||
# // alternate between push/pop until compaction occurs
|
||||
# lfs_block_t before_block = btree.u.r.rbyd.block;
|
||||
# for (lfs_block_t i = 0;; i++) {
|
||||
# // a bit hacky, but this catches infinite loops
|
||||
# assert(i < BLOCK_SIZE);
|
||||
#
|
||||
# // pop!
|
||||
# lfsr_btree_pop(&lfs, &btree, SIBLING) => 0;
|
||||
#
|
||||
# assert(lfsr_btree_weight(&btree) == 1);
|
||||
#
|
||||
# // try looking up tag to hopefully catch if something breaks
|
||||
# uint8_t buffer[4];
|
||||
# lfsr_tag_t tag_;
|
||||
# lfs_size_t weight_;
|
||||
#
|
||||
# lfsr_btree_get(&lfs, &btree, 0,
|
||||
# &tag_, &weight_, buffer, 4) => 1;
|
||||
# assert(tag_ == LFSR_TAG_INLINED);
|
||||
# assert(weight_ == 1);
|
||||
# assert(memcmp(buffer, (SIBLING == 1 ? "a" : "b"), 1) == 0);
|
||||
#
|
||||
# // inlined? consider this a success
|
||||
# if (lfsr_btree_isinlined(&btree)) {
|
||||
# break;
|
||||
# }
|
||||
#
|
||||
# // abort if a compaction occurs
|
||||
# if (btree.u.r.rbyd.block != before_block) {
|
||||
# break;
|
||||
# }
|
||||
#
|
||||
# // push!
|
||||
# lfsr_btree_push(&lfs, &btree, SIBLING, LFSR_TAG_INLINED, 1,
|
||||
# LFSR_DATA("c", 1)) => 0;
|
||||
#
|
||||
# // try looking up tag to hopefully catch if something breaks
|
||||
# lfsr_btree_get(&lfs, &btree, 0,
|
||||
# &tag_, &weight_, buffer, 4) => 1;
|
||||
# assert(tag_ == LFSR_TAG_INLINED);
|
||||
# assert(weight_ == 1);
|
||||
# assert(memcmp(buffer, (SIBLING == 1 ? "a" : "c"), 1) == 0);
|
||||
#
|
||||
# lfsr_btree_get(&lfs, &btree, 1,
|
||||
# &tag_, &weight_, buffer, 4) => 1;
|
||||
# assert(tag_ == LFSR_TAG_INLINED);
|
||||
# assert(weight_ == 1);
|
||||
# assert(memcmp(buffer, (SIBLING == 1 ? "c" : "b"), 1) == 0);
|
||||
#
|
||||
# // inlined? consider this a success
|
||||
# if (lfsr_btree_isinlined(&btree)) {
|
||||
# break;
|
||||
# }
|
||||
#
|
||||
# // abort if a compaction occurs
|
||||
# if (btree.u.r.rbyd.block != before_block) {
|
||||
# break;
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# printf("btree: w%d 0x%x.%x\n",
|
||||
# btree.u.r.rbyd.weight,
|
||||
# btree.u.r.rbyd.block,
|
||||
# btree.u.r.rbyd.trunk);
|
||||
#'''
|
||||
|
||||
|
||||
# Some more general fuzz testing
|
||||
|
||||
Reference in New Issue
Block a user