HomePhabricator

Merge #16957: 9% less memory: make SaltedOutpointHasher noexcept

Description

Merge #16957: 9% less memory: make SaltedOutpointHasher noexcept

Summary:
67d99900b0d770038c9c5708553143137b124a6c make SaltedOutpointHasher noexcept (Martin Ankerl)

Pull request description:

If the hash is not `noexcept`, `unorderd_map` has to assume that it can throw an exception. Thus when rehashing care needs to be taken. libstdc++ solves this by simply caching the hash value, which increases memory of each node by 8 bytes. Adding `noexcept` prevents this caching. In my experiments with `-reindex-chainstate -stopatheight=594000`, memory usage (maximum resident set size) has decreased by 9.4% while runtime has increased by 1.6% due to additional hashing. Additionally, memusage::DynamicUsage() is now more accurate and does not underestimate.

|                                       | runtime h:mm:ss | max RSS kbyte |
|---------------------------------------|-----------------|--------------|
| master                                |         4:13:59 |      7696728 |
| 2019-09-SaltedOutpointHasher-noexcept |         4:18:11 |      6971412 |
| change                                |          +1.65% |       -9,42% |

Comparison of progress masters vs. 2019-09-SaltedOutpointHasher-noexcept
![out](https://user-images.githubusercontent.com/14386/65541887-69424e00-df0e-11e9-8644-b3a068ed8c3f.png)

Backport of Core PR16957

Release notes were backported from Core PR17422

Test Plan: ninja check check-functional for sanity

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

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

Details

Provenance
Wladimir J. van der Laan <laanwj@protonmail.com>Authored on Oct 20 2020, 17:26
jasonbcoxCommitted on Oct 20 2020, 17:27
abc-botPushed on Oct 20 2020, 17:33
Reviewer
Restricted Project
Differential Revision
D7996: Merge #16957: 9% less memory: make SaltedOutpointHasher noexcept
Parents
rABCa87c1a8f2312: Merge #16931: test: add unittests for CheckProofOfWork
Branches
Unknown
Tags
Unknown