diff options
author | Ava Chow <github@achow101.com> | 2024-03-11 09:34:19 -0400 |
---|---|---|
committer | Ava Chow <github@achow101.com> | 2024-03-11 09:59:35 -0400 |
commit | 6dda050865e298e2e3d5f23a8435981d1e017dbe (patch) | |
tree | 5302a243f6b30f094a922685482f700789c55de8 /test | |
parent | 02c7fd8df4d7bff846e22c72c51ff5959dcb729f (diff) | |
parent | a19235c14b3dc02de30b5d769de29d1752c23dbd (diff) | |
download | bitcoin-6dda050865e298e2e3d5f23a8435981d1e017dbe.tar.xz |
Merge bitcoin/bitcoin#29458: refactor: Preallocate result in TryParseHex to avoid resizing
a19235c14b3dc02de30b5d769de29d1752c23dbd Preallocate result in `TryParseHex` to avoid resizing (Lőrinc)
b7489ecb52c1f99facb7c81c5e46963394d0620d Add benchmark for TryParseHex (Lőrinc)
Pull request description:
This pull request introduces optimizations to the `TryParseHex` function, focusing primarily on the ideal case (valid hexadecimal input without spaces).
A new benchmark, `HexParse` was introduced in a separate commit.
The main optimization preallocates the result vector based on the input string's length. This aims to completely avoid costly dynamic reallocations when no spaces are present.
------------
Before:
```
| ns/base16 | base16/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 1.60 | 623,238,893.11 | 0.3% | 0.01 | `HexParse`
| 1.65 | 606,747,566.34 | 0.6% | 0.01 | `HexParse`
| 1.60 | 626,149,544.07 | 0.3% | 0.01 | `HexParse`
```
After:
```
| ns/base16 | base16/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 0.68 | 1,465,555,976.27 | 0.8% | 0.01 | `HexParse`
| 0.68 | 1,472,962,920.18 | 0.3% | 0.01 | `HexParse`
| 0.68 | 1,476,159,423.00 | 0.3% | 0.01 | `HexParse`
```
ACKs for top commit:
achow101:
ACK a19235c14b3dc02de30b5d769de29d1752c23dbd
hebasto:
ACK a19235c14b3dc02de30b5d769de29d1752c23dbd.
andrewtoth:
Re-ACK a19235c14b3dc02de30b5d769de29d1752c23dbd
Empact:
Re-ACK https://github.com/bitcoin/bitcoin/pull/29458/commits/a19235c14b3dc02de30b5d769de29d1752c23dbd
Tree-SHA512: e09a59791104be3fd1026862ce98de9efafa1f949626fa01e3b7d58e6a2ef02a11f0de55ddba5c43230a53effd24e6d368c1e12848b17e8ce91d7908a59333f0
Diffstat (limited to 'test')
0 files changed, 0 insertions, 0 deletions