Skip to content
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

Hashing BitIntegers.jl Integers is slow #43

Open
MSRudolph opened this issue May 30, 2024 · 0 comments
Open

Hashing BitIntegers.jl Integers is slow #43

MSRudolph opened this issue May 30, 2024 · 0 comments

Comments

@MSRudolph
Copy link

Hello,

I am thankful for your package because bit operations with your integer implementation is much faster than with BigInt. However, my code is quite sensitive to the hashing speed, and it seems like that is slow. See the example below:

using BenchmarkTools
using BitIntegers

val1 = convert(UInt128, 123456789)
val2 = convert(UInt256, val1)
val3 = convert(UInt512, val2)
val4 = convert(UInt1024, val3)
val5 = convert(BigInt, val4)

@btime hash($val1)
@btime hash($val2)
@btime hash($val3)
@btime hash($val4)
@btime hash($val5)

>
3.182 ns (0 allocations: 0 bytes)
33.816 ns (2 allocations: 40 bytes)
55.711 ns (2 allocations: 40 bytes)
67.377 ns (2 allocations: 40 bytes)
3.136 ns (0 allocations: 0 bytes)

This shows up to a 20x slowdown over BigInts. Is there something that can be done?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant