laanwj
fe6a299fc0
Merge bitcoin/bitcoin#24852: util: optimize HexStr
5e61532e72c1021fda9c7b213bd9cf397cb3a802 util: optimizes HexStr (Martin Leitner-Ankerl)
4e2b99f72a90b956f3050095abed4949aff9b516 bench: Adds a benchmark for HexStr (Martin Leitner-Ankerl)
67c8411c37b483caa2fe3f7f4f40b68ed2a9bcf7 test: Adds a test for HexStr that checks all 256 bytes (Martin Leitner-Ankerl)
Pull request description:
In my benchmark, this rewrite improves runtime 27% (g++) to 46% (clang++) for the benchmark `HexStrBench`:
g++ 11.2.0
| ns/byte | byte/s | err% | ins/byte | cyc/byte | IPC | bra/byte | miss% | total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
| 0.94 | 1,061,381,310.36 | 0.7% | 12.00 | 3.01 | 3.990 | 1.00 | 0.0% | 0.01 | `HexStrBench` master
| 0.68 | 1,465,366,544.25 | 1.7% | 6.00 | 2.16 | 2.778 | 1.00 | 0.0% | 0.01 | `HexStrBench` branch
clang++ 13.0.1
| ns/byte | byte/s | err% | ins/byte | cyc/byte | IPC | bra/byte | miss% | total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
| 0.80 | 1,244,713,415.92 | 0.9% | 10.00 | 2.56 | 3.913 | 0.50 | 0.0% | 0.01 | `HexStrBench` master
| 0.43 | 2,324,188,940.72 | 0.2% | 4.00 | 1.37 | 2.914 | 0.25 | 0.0% | 0.01 | `HexStrBench` branch
Note that the idea for this change comes from denis2342 in #23364. This is a rewrite so no unaligned accesses occur.
Also, the lookup table is now calculated at compile time, which hopefully makes the code a bit easier to review.
ACKs for top commit:
laanwj:
Code review ACK 5e61532e72c1021fda9c7b213bd9cf397cb3a802
aureleoules:
tACK 5e61532e72c1021fda9c7b213bd9cf397cb3a802.
theStack:
ACK 5e61532e72c1021fda9c7b213bd9cf397cb3a802 🚤
Tree-SHA512: 40b53d5908332473ef24918d3a80ad1292b60566c02585fa548eb4c3189754971be5a70325f4968fce6d714df898b52d9357aba14d4753a8c70e6ffd273a2319
2022-05-04 20:36:09 +02:00
..
2022-04-20 14:29:29 +01:00
2020-12-31 09:45:41 +01:00
2021-12-30 19:36:57 +02:00
2022-03-02 12:09:27 +01:00
2022-02-04 09:33:41 -05:00
2022-02-04 09:33:41 -05:00
2021-12-30 19:36:57 +02:00
2021-12-30 19:36:57 +02:00
2020-12-31 09:45:41 +01:00
2020-12-06 00:48:09 +00:00
2022-01-02 11:40:31 +01:00
2022-04-28 20:34:43 +02:00
2022-03-25 21:27:39 +00:00
2021-12-30 19:36:57 +02:00
2021-12-30 19:36:57 +02:00
2021-12-30 19:36:57 +02:00
2022-02-17 17:25:57 +01:00
2020-12-31 09:45:41 +01:00
2020-12-31 09:45:41 +01:00
2020-12-31 09:45:41 +01:00
2021-12-15 14:33:59 +01:00
2021-12-30 19:36:57 +02:00
2022-04-04 09:01:19 +01:00
2020-06-13 12:24:18 +02:00
2020-06-13 12:24:18 +02:00
2021-09-21 11:46:01 +02:00
2021-12-13 13:32:08 +01:00
2020-12-31 09:45:41 +01:00
2021-12-30 19:36:57 +02:00
2022-04-06 13:57:31 +01:00
2022-04-19 14:34:56 -04:00
2022-04-04 09:01:19 +01:00
2022-04-17 14:29:52 +02:00
2020-12-31 09:45:41 +01:00
2021-12-30 19:36:57 +02:00
2022-04-04 09:01:19 +01:00
2022-04-18 17:02:57 -04:00