ecmult_multi: reduce strauss memory usage by 30% #1761
pull jonasnick wants to merge 1 commits into bitcoin-core:master from jonasnick:strauss-mem changing 1 files +19 −4-
jonasnick commented at 2:28 pm on October 17, 2025: contributorThis is a draft because I’m not sure about the cleanest way to implement it.
-
ecmult_multi: reduce strauss memory usage by 30% 26166c4f5f
-
real-or-random added the label performance on Oct 27, 2025
-
real-or-random commented at 8:02 am on October 27, 2025: contributor
This is a draft because I’m not sure about the cleanest way to implement it.
The current approach looks clean. What other approaches do you have in mind?
-
real-or-random added the label tweak/refactor on Oct 27, 2025
-
in src/ecmult_impl.h:239 in 26166c4f5f
236+} 237+ 238 struct secp256k1_strauss_point_state { 239- int wnaf_na_1[129]; 240- int wnaf_na_lam[129]; 241+ int8_t wnaf_na_1[129];
real-or-random commented at 8:10 am on October 27, 2025:0 int_least8_t wnaf_na_1[129];This is technically better to retain support for platforms that don’t offer
int8_t. I don’t think there are any relevant platforms of that kind, but why not… 🤷edit: Now that I think about it again, a platform that does not offer
int8_twill most likely one for whichCHAR_BITS != 8. And then it’s neither relevant nor it’s likely to offerint32_torint64_twhich we need anyway. So I guess there’s no difference betweenint8_tandint_least8_t.
hebasto commented at 4:58 pm on October 27, 2025:This is technically better to retain support for platforms that don’t offer
int8_t.int8_tis already used insrc/assumptions.h.hebasto commented at 4:47 pm on October 27, 2025: memberConcept ACK.hebasto commented at 6:00 pm on October 27, 2025: memberOn my x86_64 system, this PR reduces the memory allocated on the scratch space from 2224 bytes to 1452 bytes per point.
Please ping me once it’s undrafted.
jonasnick commented at 6:52 pm on October 27, 2025: contributorThe current approach requires a temporary array
int wnaf_tmp[256];to provide tosecp256k1_ecmult_wnafwhich looks unclean. The alternatives are- copy almost all of
secp256k1_ecmult_wnafintosecp256k1_ecmult_wnaf_small, or - remove
secp256k1_ecmult_wnaf_smalland write ansecp256k1_ecmultmacro.
Both options seem to be worse.
hebasto commented at 10:00 pm on October 27, 2025: memberThe current approach requires a temporary array
int wnaf_tmp[256];to provide tosecp256k1_ecmult_wnafwhich looks unclean. The alternatives are-
copy almost all of
secp256k1_ecmult_wnafintosecp256k1_ecmult_wnaf_small, or -
remove
secp256k1_ecmult_wnaf_smalland write ansecp256k1_ecmultmacro.
Both options seem to be worse.
I might suggest a third option: https://github.com/hebasto/secp256k1/commit/5c0d6eeeb2ec9dc8de92f59cf7647a30e6826dcb.
This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-10-30 21:15 UTC
More mirrored repositories can be found on mirror.b10c.me