Files
bitcoin/src
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-05-08 16:49:58 +01:00
2025-07-11 15:18:22 +02:00
2025-05-19 16:40:33 +01:00
2025-05-19 16:40:33 +01:00
2025-05-20 09:30:41 +01:00
2024-11-26 20:47:08 -05:00
2025-05-19 16:40:33 +01:00
2025-05-06 12:21:32 -07:00
2025-05-19 16:40:33 +01:00
2025-07-14 16:13:10 -04:00
2024-11-04 14:19:40 -05:00
2024-05-20 16:48:19 +00:00
2024-07-08 11:12:01 +02:00
2025-06-03 08:09:21 +01:00
2025-05-08 16:49:58 +01:00
2025-04-09 15:59:59 +01:00
2025-04-09 15:59:59 +01:00