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

Round LRU time to nearest 32 seconds #4317

Closed
wants to merge 1 commit into from

Conversation

RickiNano
Copy link
Contributor

@RickiNano RickiNano commented Oct 25, 2023

By rounding LRU time we are more likely to get AEC aligned across the network because blocks that are published very fast are grouped in 32 seconds "slots" that are sorted by hash.
This pr uses a 5 bit mask for rounding for best performance.
60 seconds rounding has been suggested but I chose 32 seconds to err on the side of caution and because Piotr mentioned that down to 15 seconds might be enough

@qwahzi
Copy link
Collaborator

qwahzi commented Oct 25, 2023

Related issue with more details, for reference: #4169

@@ -35,7 +35,10 @@ void nano::scheduler::bucket::pop ()

void nano::scheduler::bucket::push (uint64_t time, std::shared_ptr<nano::block> block)
{
queue.insert ({ time, block });
const uint64_t bitmask = ~0b11111;
uint64_t rounded_time = time & bitmask;
Copy link
Contributor

Choose a reason for hiding this comment

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

For readability I would strongly suggest to keep a normal division. Our bottleneck is IO which is many orders of magnitude slower anyway, this division is noop when it comes to performance

@RickiNano
Copy link
Contributor Author

This PR has been tested on the beta network.
The saturation point before introducing LRU rounding was 650 bps. With a 32 seconds LRU rounding, saturation increased to 900 bps.
We never tested 900 bps with the previous version but here is a comparison of 850 bps (no rounding) vs 900 bps (with 32 seconds rounding)
image

@RickiNano
Copy link
Contributor Author

The performance improvement that was shown on the beta network turned out to be caused by a problem with one of the nodes that was fixed just after the LRU rounding version was installed.
From further testing it seems that the performance gained is minimal so I will close this PR for now

@RickiNano RickiNano closed this Oct 29, 2023
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