From d3fe99ed98efe2f73f06b616080309387a60e61f Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sun, 26 Jan 2025 15:12:02 -0600 Subject: [PATCH] rbyd: Fixed ambiguous stitching alt fix What a funny bug. I was wondering how jump ended up == branch, it turns out this was a simple typo in the diverged-stitching rework. What's extra humorous is I think the original code was trying to set branch_ = jump, which wouldn't have worked. So the typo actually got diverged-stitching to a more workable state than if there was no typo. It just then broke the y-split logic. Not randomly changing the branch when stitching is the correct fix. --- This doesn't actually reduce any test failures since it's replacing the previous jump >= branch "fix", which was really just a bandaid: test_rbyd+balance before: 1671/385878 failed test_rbyd+balance after: 1671/385878 failed (+0.0%) Saves one ld/st though: code stack ctx before: 38584 2624 640 after: 38580 (-0.0%) 2624 (+0.0%) 640 (+0.0%) --- lfs.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lfs.c b/lfs.c index 510ff175..c29dd43c 100644 --- a/lfs.c +++ b/lfs.c @@ -3793,7 +3793,7 @@ trunk:; // - lfs_smax(-rat.weight, 0) // - (weight - (d_rid - lower_rid)); weight -= delta; - branch = jump; +// branch_ = jump; // lower_rid += lfs_smax(-rat.weight, 0); lower_rid += delta; @@ -3992,13 +3992,7 @@ trunk:; if (branch_ < branch) { LFS_DEBUG("%04x->%04x: ysplit b", branch, lfsr_rbyd_eoff(rbyd)); - // TODO this shouldn't happen? - // TODO hwat, >= solves this?? - if (jump == branch){ - LFS_DEBUG("%04x->%04x: ysplit b jump == branch", - branch, lfsr_rbyd_eoff(rbyd)); - } - if (jump >= branch) { + if (jump > branch) { LFS_SWAP(lfsr_tag_t, &p[0].alt, &alt); LFS_SWAP(lfsr_rid_t, &p[0].weight, &weight); LFS_SWAP(lfs_size_t, &p[0].jump, &jump);