Skip to content

Simpler rank0#30

Closed
ArseniyKorobenko wants to merge 5 commits intoCydhra:masterfrom
ArseniyKorobenko:simpler-rank0
Closed

Simpler rank0#30
ArseniyKorobenko wants to merge 5 commits intoCydhra:masterfrom
ArseniyKorobenko:simpler-rank0

Conversation

@ArseniyKorobenko
Copy link

The idea is that to calculate rank1 we can just subtract rank0 from the current position.
This lets us simplify the rank() function's logic d163337 and not have to keep track of redundant data b2cd1bd

I made sure to run the tests and benchmarks, to ensure that there were no performance regressions.

@Cydhra
Copy link
Owner

Cydhra commented Mar 9, 2025

I'm trying so hard to remember why I didn't do this to begin with, so I will not merge immediately until I either remember why, or decide that it doesn't matter.

In any case, I consider removing rank1 from the struct a breaking change due to the serde-compatibility. So either you have to revert that and leave the now-useless constant in there (I will add a note to #9), or this PR is blocked until 2.0 (which I will probably begin work on soon, but it will take a lot of work and time).

@Cydhra
Copy link
Owner

Cydhra commented Mar 9, 2025

Oh and you forgot to update the testcases with the rank1 constant, though this is irrelevant if you revert that change.

@ArseniyKorobenko
Copy link
Author

Yeah I wasn't sure about that one either. reverted.

@Cydhra Cydhra added the enhancement New feature or request label Mar 9, 2025
@Cydhra Cydhra self-assigned this Mar 9, 2025
@Cydhra
Copy link
Owner

Cydhra commented Mar 10, 2025

I measure a performance degradation of 5-10% for rank1.

@Cydhra
Copy link
Owner

Cydhra commented Mar 10, 2025

It is unclear to me where the performance hit is coming from. It is possible that this is just an artifact of the microbenchmark, though, iirc, I originally didn't use this approach because I was already measuring performance degradation back then, which was on a different setup and so benchmarking artifacts are less likely.

It should be noted that this PR only affects code readability, you are not actually improving branching, as the parameter the branches depend on is constant. Still, I'd expect this to be as fast as the current implementation, but at least in the microbenchmark it is consistently slower.

@Cydhra
Copy link
Owner

Cydhra commented Apr 23, 2025

Well, even after retrying, i cant get this to work without a performance regression. I don't know if the regression is real, because I don't have realistic benchmarks at hand.

I will close this until it can be shown that the regression is either a weirdly reproducable artifact of microbenchmarking, or a version of this can be found that doesn't regress.

@Cydhra Cydhra closed this Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants