Page MenuHomePhabricator

Unroll the ChaCha20 inner loop for performance
ClosedPublic

Authored by PiRK on Oct 21 2025, 17:27.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC72011bf44763: Unroll the ChaCha20 inner loop for performance
Summary

This is a backport of core#24946

before:

ns/bytebyte/serr%totalbenchmark
--------------------:--------------------:--------:----------::----------
1.06943,492,622.220.2%0.01CHACHA20_1MB
1.07931,649,398.020.1%0.01CHACHA20_256BYTES
1.09915,389,200.840.3%0.01CHACHA20_64BYTES
2.84352,270,814.640.2%0.03CHACHA20_POLY1305_AEAD_1MB_ENCRYPT_DECRYPT
1.42703,771,093.980.1%0.02CHACHA20_POLY1305_AEAD_1MB_ONLY_ENCRYPT
3.80262,822,693.771.0%0.01CHACHA20_POLY1305_AEAD_256BYTES_ENCRYPT_DECRYPT
1.92521,278,538.030.4%0.01CHACHA20_POLY1305_AEAD_256BYTES_ONLY_ENCRYPT
6.61151,253,004.430.2%0.01CHACHA20_POLY1305_AEAD_64BYTES_ENCRYPT_DECRYPT
3.32301,294,073.340.2%0.01CHACHA20_POLY1305_AEAD_64BYTES_ONLY_ENCRYPT

after:

ns/bytebyte/serr%totalbenchmark
--------------------:--------------------:--------:----------::----------
1.02979,048,846.190.0%0.01CHACHA20_1MB
1.04957,913,356.570.2%0.01CHACHA20_256BYTES
1.08923,578,665.640.3%0.01CHACHA20_64BYTES
2.77360,586,442.660.1%0.03CHACHA20_POLY1305_AEAD_1MB_ENCRYPT_DECRYPT
1.39721,889,319.700.1%0.02CHACHA20_POLY1305_AEAD_1MB_ONLY_ENCRYPT
3.71269,635,408.140.1%0.01CHACHA20_POLY1305_AEAD_256BYTES_ENCRYPT_DECRYPT
1.86537,671,468.950.2%0.01CHACHA20_POLY1305_AEAD_256BYTES_ONLY_ENCRYPT
6.53153,238,853.300.3%0.01CHACHA20_POLY1305_AEAD_64BYTES_ENCRYPT_DECRYPT
3.27305,392,217.410.1%0.01CHACHA20_POLY1305_AEAD_64BYTES_ONLY_ENCRYPT
Test Plan

ninja all check-all bench-bitcoin

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Oct 21 2025, 17:27
Fabien added a subscriber: Fabien.

This would be done by the compiler with O3 and a normal loop pattern, but ok

This revision is now accepted and ready to land.Oct 22 2025, 07:39