Commit eb13718
committed
Merge bitcoin/bitcoin#31179: RPC: Add reserve member function to
5d82d92 rpc: reserve space for `UniValue` variables in `blockToJSON` (ismaelsadeeq)
6a506d5 UniValue: add reserve member function (ismaelsadeeq)
bd46119 bench: support benching all verbosity of `BlockToJson` (ismaelsadeeq)
Pull request description:
This PR is motivated by bitcoin/bitcoin#30495 (comment),
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 5d82d92 🐀
l0rinc:
ACK 5d82d92
achow101:
ACK 5d82d92
Eunovo:
Re-ACK bitcoin/bitcoin@5d82d92
Tree-SHA512: bdd2c1bcdc4d060d30ad3be0b10f0d722dda0c2286bc4156af851503220e8854e76a4dc53456826b543c110982455268838172d3a1026eee754d4c673b48ea05UniValue and use it in blockToJSON functionFile tree
5 files changed
+33
-3
lines changed- src
- bench
- rpc
- univalue
- include
- lib
5 files changed
+33
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
59 | 76 | | |
60 | 77 | | |
61 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
| |||
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
| 207 | + | |
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
| |||
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
| 237 | + | |
235 | 238 | | |
236 | 239 | | |
237 | 240 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
189 | 190 | | |
190 | 191 | | |
191 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
0 commit comments