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%)
This commit is contained in:
Christopher Haster
2025-01-26 15:12:02 -06:00
parent 8e919df1b8
commit d3fe99ed98
+2 -8
View File
@@ -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);