Skip to content

Hashing BitIntegers.jl Integers is slow #43

Description

@MSRudolph

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions