lighthouse/consensus
Michael Sproul 2c691af95b Use hardware acceleration for SHA256 (#2426)
## Proposed Changes

Modify the SHA256 implementation in `eth2_hashing` so that it switches between `ring` and `sha2` to take advantage of [x86_64 SHA extensions](https://en.wikipedia.org/wiki/Intel_SHA_extensions). The extensions are available on modern Intel and AMD CPUs, and seem to provide a considerable speed-up: on my Ryzen 5950X it dropped state tree hashing times by about 30% from 35ms to 25ms (on Prater).

## Additional Info

The extensions became available in the `sha2` crate [last year](https://www.reddit.com/r/rust/comments/hf2vcx/ann_rustcryptos_sha1_and_sha2_now_support/), and are not available in Ring, which uses a [pure Rust implementation of sha2](https://github.com/briansmith/ring/blob/main/src/digest/sha2.rs). Ring is faster on CPUs that lack the extensions so I've implemented a runtime switch to use `sha2` only when the extensions are available. The runtime switching seems to impose a miniscule penalty (see the benchmarks linked below).
2021-07-12 08:47:01 +00:00
..
cached_tree_hash rust 1.53.0 updates (#2411) 2021-06-18 05:58:01 +00:00
fork_choice Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
int_to_bytes Update to tokio 1.1 (#2172) 2021-02-10 23:29:49 +00:00
merkle_proof Implement matches! macro (#1777) 2020-10-15 21:42:43 +00:00
proto_array Advance state to next slot after importing block (#2174) 2021-02-15 07:17:52 +00:00
safe_arith Remove saturating arith from state_processing (#1644) 2020-09-25 05:18:21 +00:00
serde_utils Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
ssz Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
ssz_derive Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
ssz_types Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
state_processing Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
swap_or_not_shuffle Use hardware acceleration for SHA256 (#2426) 2021-07-12 08:47:01 +00:00
tree_hash Use hardware acceleration for SHA256 (#2426) 2021-07-12 08:47:01 +00:00
tree_hash_derive Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
types Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00