HomePhabricator

UniValue performance speedups for .write()

Description

UniValue performance speedups for .write()

Summary:
Inspired by https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/commit/472118a0da52c480f18430cc97ea31950d48324e
with a number of fixups that:

  • Improve internal linkage.
  • Reduce code ownership where unnecessary ownership was taken.
  • Keeps API reasonably consistent with original UniValue code.
  • Various formatting, comments, and style fixes.

Depends on D5981 for the test plan

Test Plan:

ninja check check-functional

Run this before and after patch:

./src/bench/bitcoin-bench -filter=BlockToJsonVerbose

Observe ~3-4% speedup.

Verify internal linkage:

cmake -GNinja -DCMAKE_CXX_FLAGS="-emit-llvm -S" ..
ninja univalue
grep "define internal" src/univalue/libunivalue.a

I was only able to verify internal linkage for writeAny() and escapeJson(). Not the other UniValueStreamWriter functions.

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5982

Details

Provenance
jasonbcoxAuthored on May 6 2020, 22:38
jasonbcoxPushed on May 7 2020, 18:35
Reviewer
Restricted Project
Differential Revision
D5982: UniValue performance speedups for .write()
Parents
rABCa890296d4908: Move DisconnectResult in its own header and make it an enum class
Branches
Unknown
Tags
Unknown