-
Notifications
You must be signed in to change notification settings - Fork 83
chore: replace dashu math library with num-bigint in pallas-math #662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
chore: replace dashu math library with num-bigint in pallas-math #662
Conversation
|
Did you test the performance implications of this? Num-bigint was slow to validate blocks when I tested various math libraries back in the day. |
I will report back later today after I have the benchmarks completed. |
|
ln, pow, ref_ln, and ref_pow are pretty heavily utilized in validating the block headers. This confirms what I found when I built out and tested num_bigint originally. For those important operations, it's not quite 2x as slow, but it's close. In my testing (less formal), rug was the fastest but incompatible on windows. Malachite was next best, but the developer wouldn't change the license. Dashu was after that and num_bigint was the slowest. If you want to dig through the version history of pallas_math, you can probably find my implementations of all of these. |
|
@scarmuega @KtorZ how would you like to proceed here? I see a couple of options:
|
|
I would prefer sticking to one library; and I don't think the performances should be the sole argument. Both libraries have very decent perfs and I hardly think that any will constitute a bottleneck in block header validations. Also, rather than comparing rust libs against one another in terms of perfs, we should compare rust lib with the current Haskell implementation. Because if they're all slower, then they all equally suck :). But what are the other factors?
One way for way with Pallas could be to enable either depending on feature flags; although I think Pallas already went down that path and came back? So perhaps there's no interest in supporting multiple maths libraries. |
|
I think all of that is sensible. It might be worth writing a benchmark specifically for header validation, and just establish a reference budget using the haskell node numbers. |
|
The golden tests in the haskell code are a good benchmark to hit. The reference C code that haskell is matching used gmp which is used by rug. |
|
The performance of the library is quite import to cncli in the leadership calculation. If Amaru does the calculation every second like the haskell node does but performs worse, that's an issue. My original design used rug as a feature flag so if you really wanted the best performance, you could get it. |

This PR removes the dashu math library dependency and replaces it with num-bigint to standardize math operations across the codebase, improving consistency.