Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change gap cache voters to use a vector #2037

Merged

Conversation

@wezrule
Copy link
Collaborator

commented May 27, 2019

While checking for heap memory allocations there is a lot in the gap_cache::add function (default std::unordered_set constructor which sets up the initial hash table). The number of voters is quite small so I decided to benchmark if using a std::vector would offer any benefits. As the number of voters gradually increases, where it checks for existing nano::account objects and iterates over the whole collection each time, I recorded an equivalent scenario at various intervals with 2 different compilers:
http://quick-bench.com/psAI43n2tRg9ZLw4AER3cehYXJs

Voters Clang 7 gcc 8.2
5 1.9x 3.2x
20 2.4x 4.3x
100 2.1x 13x
255 1.6x 27x

The x denotes how many times faster the std::vector version is over the std::unordered_set. The results both show an increase for clang and gcc using a std::vector, which is what I've changed it to use.

@wezrule wezrule added the performance label May 27, 2019

@wezrule wezrule added this to the V19.0 milestone May 27, 2019

@wezrule wezrule requested a review from cryptocode May 27, 2019

@wezrule wezrule self-assigned this May 27, 2019

@wezrule wezrule merged commit a65fea7 into nanocurrency:master May 28, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@wezrule wezrule deleted the wezrule:change_gap_cache_votes_to_vector branch May 28, 2019

@zhyatt zhyatt added this to RC 4 (TBD) in V19 May 30, 2019

argakiig added a commit that referenced this pull request Jun 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.