Ava Chow
eb13718448
Merge bitcoin/bitcoin#31179: RPC: Add reserve member function to UniValue and use it in blockToJSON function
5d82d92aff rpc: reserve space for `UniValue` variables in `blockToJSON` (ismaelsadeeq)
6a506d5c37 UniValue: add reserve member function (ismaelsadeeq)
bd461195f4 bench: support benching all verbosity of `BlockToJson` (ismaelsadeeq)
Pull request description:
This PR is motivated by https://github.com/bitcoin/bitcoin/issues/30495#issuecomment-2444881418,
It adds a `reserve` member function to `UniValue` and applies it within the `blockToJSON` function to pre-allocate memory, minimizing reallocation's.
<details>
<summary>Slight performance increase in verbosity 1</summary>
On **master**:
| ns/op | op/s | err% | total | benchmark |
|--------------:|------------:|------:|------:|:------------------------|
| 190,342 | 5,254 | 2.3% | 0.01 | `BlockToJsonVerbose1` |
| 34,812,292 | 28.73 | 1.0% | 0.38 | `BlockToJsonVerbose2` |
| 34,457,167 | 29.02 | 1.0% | 0.38 | `BlockToJsonVerbose3` |
On **this PR**:
| ns/op | op/s | err% | total | benchmark |
|--------------:|------------:|------:|------:|:------------------------|
| 172,278 | 5,805 | 0.7% | 0.01 | `BlockToJsonVerbose1` |
| 33,720,584 | 29.66 | 0.4% | 0.37 | `BlockToJsonVerbose2` |
| 33,884,417 | 29.51 | 1.2% | 0.38 | `BlockToJsonVerbose3` |
</details>
ACKs for top commit:
maflcko:
review ACK 5d82d92aff 🐀
l0rinc:
ACK 5d82d92aff
achow101:
ACK 5d82d92aff
Eunovo:
Re-ACK 5d82d92aff
Tree-SHA512: bdd2c1bcdc4d060d30ad3be0b10f0d722dda0c2286bc4156af851503220e8854e76a4dc53456826b543c110982455268838172d3a1026eee754d4c673b48ea05
2025-07-23 13:29:07 -07:00
..
2025-07-23 13:29:07 -07:00
2025-06-11 15:08:23 -07:00
2025-06-03 19:56:55 +02:00
2025-06-03 19:56:55 +02:00
2025-07-11 15:18:22 +02:00
2025-07-11 13:47:19 -04:00
2025-06-19 16:29:55 +02:00
2025-06-03 19:56:55 +02:00
2025-05-30 16:51:49 +01:00
2025-07-21 11:01:12 -04:00
2025-07-18 13:24:54 -07:00
2025-07-11 13:47:19 -04:00
2025-07-11 14:26:16 +01:00
2025-07-23 13:29:07 -07:00
2025-07-02 15:06:33 +01:00
2025-07-22 09:35:01 +01:00
2025-07-22 11:19:18 -07:00
2025-07-23 13:29:07 -07:00
2025-07-16 14:37:19 -07:00
2025-07-16 14:27:17 +05:30
2025-06-13 19:19:44 +03:00
2025-06-03 15:13:54 +02:00
2025-07-10 11:24:40 +02:00
2025-06-03 15:13:54 +02:00
2025-06-03 15:13:57 +02:00
2025-06-03 15:13:57 +02:00
2025-06-03 19:56:55 +02:00
2025-06-10 15:14:24 +02:00
2025-06-10 15:14:24 +02:00
2025-06-10 15:14:24 +02:00
2025-06-10 15:14:24 +02:00
2025-06-10 15:14:24 +02:00
2025-06-10 15:14:24 +02:00
2025-06-10 10:07:56 -04:00
2025-06-10 10:07:56 -04:00
2025-06-12 14:40:59 -04:00
2025-06-03 15:13:57 +02:00
2025-05-29 11:18:36 +01:00
2025-06-03 19:56:55 +02:00
2025-07-22 09:35:01 +01:00
2025-06-03 15:13:57 +02:00
2025-07-16 14:33:07 -07:00
2025-07-16 14:33:07 -07:00
2025-06-16 15:33:19 +02:00
2025-07-03 06:26:23 -04:00
2025-06-06 15:31:36 -07:00
2025-07-14 16:13:10 -04:00
2025-06-03 15:13:57 +02:00
2025-07-09 09:13:00 -04:00
2025-07-09 09:13:00 -04:00
2025-07-17 12:43:04 -04:00
2025-07-14 16:13:10 -04:00
2025-07-14 16:13:10 -04:00
2025-06-16 15:33:15 +02:00
2025-06-03 08:09:21 +01:00
2025-06-30 13:28:17 -04:00
2025-06-03 19:56:55 +02:00
2025-06-18 18:11:28 -03:00
2025-06-18 18:11:28 -03:00
2025-06-03 15:13:57 +02:00
2025-07-08 20:00:51 +01:00
2025-07-08 20:00:51 +01:00
2025-07-16 13:19:18 -07:00
2025-07-06 11:20:18 +08:00
2025-06-16 18:09:14 +00:00
2025-07-16 14:33:07 -07:00
2025-07-16 14:33:07 -07:00
2025-07-07 15:51:37 +01:00
2025-07-02 16:01:57 -04:00
2025-07-02 14:52:54 -04:00
2025-07-18 16:50:42 -07:00
2025-07-11 13:47:19 -04:00
2025-07-08 20:00:51 +01:00
2025-07-08 20:00:51 +01:00
2025-07-11 13:47:19 -04:00
2025-07-09 16:55:43 -07:00
2025-06-16 18:09:14 +00:00
2025-07-07 18:14:52 +01:00