You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia>@benchmarksha256(data)
BenchmarkTools.Trial:8884 samples with 1 evaluation.
Range (min … max):514.644 μs …913.010 μs ┊ GC (min … max):0.00%…0.00%
Time (median):518.341 μs ┊ GC (median):0.00%
Time (mean ± σ):561.483 μs ±99.395 μs ┊ GC (mean ± σ):0.00%±0.00%
This is presumably (haven't checked though) because Python's underlying C library uses SHA-specific CPU instructions, where as this package does not.
This might not be possible to fix in current versions of Julia, but given that we see a 10x performance difference, this is something Julia needs to support eventually (and probably will). When that time comes, this package should be updated.
HACL* is a formally verified library of modern cryptographic algorithms written in a subset of F* called Low* and compiled to C using a compiler called KaRaMeL.
HACL* is released in pure C, so we can wrap it and test the performance.
I'd prefer to keep the pure julia implementation and then have the fast impl. as a separate package, maybe called HashlibAcc.jl. The default is to use the pure julia impl., and if users need a faster impl., they can import the accelerated package.
The main concern is that introducing a third-party dependency may increase the maintenance burden.
Python's
hashlib.sha256(data).hexdigest()
is 10x faster than SHA.jl'ssha256(data)
on my computer:This is presumably (haven't checked though) because Python's underlying C library uses SHA-specific CPU instructions, where as this package does not.
This might not be possible to fix in current versions of Julia, but given that we see a 10x performance difference, this is something Julia needs to support eventually (and probably will). When that time comes, this package should be updated.
This issue was discovered by @jonalm
The text was updated successfully, but these errors were encountered: