Page MenuHomePhabricator

[univalue] Add a path for ignoring duplicate key checks
AbandonedPublic

Authored by jasonbcox on May 6 2020, 05:49.

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
Summary

Duplicate key checks in UniValue are expensive and dramatically
impact various serialization steps in the RPC code. A small modification to the
UniValue library gives a significant performance boost without taking on
large ownership of the library.

This patch includes the updates to UniValue as well as a proof-of-concept
modification of MempoolToJSON(). Future diffs will tackle other critical
areas such as getblocktemplate and getblock.

Inspired by https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/merge_requests/122

Depends on D5974

Test Plan
ninja
./src/bench/bitcoin-bench -filter=RpcMempool

Before patch: median ~0.325 seconds on my machine
After patch: median ~0.155 seconds on my machine
*Roughly 110% speed improvement*

Diff Detail

Repository
rABC Bitcoin ABC
Branch
univalue-ignore-dups
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 10604
Build 19018: Default Diff Build & Tests
Build 19017: arc lint + arc unit

Event Timeline

deadalnix requested changes to this revision.May 6 2020, 14:50
deadalnix added a subscriber: deadalnix.

That does not seems worth butchering the AP for, especially in an unsafe manner - what happens when you get it wrong and insert duplicate keys? Pas this boolean to change the behavior is bad, but when it is do do something that is unsafe for speed, it is especially bad.

This revision now requires changes to proceed.May 6 2020, 14:50