Skip to content

Address performance regression in vote_cache::top#4627

Merged
pwojcikdev merged 3 commits intonanocurrency:developfrom
clemahieu:revert_remove_tally_tag
May 19, 2024
Merged

Address performance regression in vote_cache::top#4627
pwojcikdev merged 3 commits intonanocurrency:developfrom
clemahieu:revert_remove_tally_tag

Conversation

@clemahieu
Copy link
Copy Markdown
Contributor

Revert c734caf which removed loop short-circuit checking for top voted-for elections.
Eliminate duplicate expression evaluation.
Use deque rather than vector for results to reduce backing reallocation.

@clemahieu clemahieu requested a review from pwojcikdev May 17, 2024 13:24
Copy link
Copy Markdown
Contributor

@pwojcikdev pwojcikdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember why I removed the by tally index, seems to make no sense.

EDIT:
Okay, so tally () is not a constant time function:

return std::accumulate (voters.begin (), voters.end (), nano::uint128_t{ 0 }, [] (auto sum, auto const & item) {
   return sum + item.weight;
});

Did you measure that the additional overhead on each insertion is worth the speedup during lookup? In any case, it's possible to implement some kind of smart tally caching to alleviate this issue and have both fast insertion and top lookup.

@qwahzi qwahzi added this to the V27 milestone May 18, 2024
@pwojcikdev pwojcikdev merged commit 5142047 into nanocurrency:develop May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants