|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2024-12-10 18:15:42
Ruben Perez wrote:
> On Tue, 10 Dec 2024, 16:35 Peter Dimov via Boost, <boost_at_[hidden]
> <mailto:boost_at_[hidden]> > wrote:
>
>
> Andrey Semashev wrote:
> > Here's the output on my machine:
> >
> > sha1_160 (1024 bytes): 1220.093078 MiB/s
> > sha1_160 (1048576 bytes): 1317.424120 MiB/s
> > sha1_160 (16777216 bytes): 1318.296514 MiB/s
> > sha2_256 (1024 bytes): 406.139530 MiB/s
> > sha2_256 (1048576 bytes): 430.141013 MiB/s
> > sha2_256 (16777216 bytes): 429.341694 MiB/s
> > sha2_512 (1024 bytes): 629.593514 MiB/s
> > sha2_512 (1048576 bytes): 712.100583 MiB/s
> > sha2_512 (16777216 bytes): 711.549426 MiB/s
> > openssl_sha1_160 (1024 bytes): 1531.142208 MiB/s
> > openssl_sha1_160 (1048576 bytes): 2759.062140 MiB/s
> > openssl_sha1_160 (16777216 bytes): 2738.579482 MiB/s
> > openssl_sha2_256 (1024 bytes): 1541.291824 MiB/s
> > openssl_sha2_256 (1048576 bytes): 2462.035414 MiB/s
> > openssl_sha2_256 (16777216 bytes): 2449.770143 MiB/s
> > openssl_sha2_512 (1024 bytes): 781.187505 MiB/s
> > openssl_sha2_512 (1048576 bytes): 1086.239840 MiB/s
> > openssl_sha2_512 (16777216 bytes): 1082.922782 MiB/s
> >
> > So, depending on the input message size, OpenSSL is faster from 1.24x
> to
> > 5.72x. Interestingly, despite what is said in Boost.Hash2
> documentation (and
> > confirmed by the test), OpenSSL's implementation of SHA2-256 is
> faster than
> > SHA2-512. This could be because of the SHA ISA extensions in my
> CPU.
>
> These are interesting timings. Originally I assumed that this is
> because OpenSSL uses SIMD. But you're right that it might
> actually use SHA-NI instead.
>
> https://en.wikipedia.org/wiki/Intel_SHA_extensions
>
> For some reason I thought that SHA-NI only supported SHA1,
> but it does support SHA2-256 as well.
>
> Is there an easy way to check what OpenSSL uses? Probably
> not because it selects the instruction set at runtime.
>
>
>
> Is it expected to reach similar levels of performance in the future using Hash2?
> Or is this not in scope for the library?
I don't see why it wouldn't be in scope; performance optimizations are never
ruled out.
Taking advantage of SHA-NI when it's statically known to be available (under
GCC/Clang -march=native, for instance) should be relatively easy to add.
Dynamic dispatch is a bit more convoluted because of constexpr but should
be possible.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk