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

Ignore duplicate txns via LRU cache #3821

Merged
merged 2 commits into from
Nov 6, 2024
Merged

Ignore duplicate txns via LRU cache #3821

merged 2 commits into from
Nov 6, 2024

Conversation

bfish713
Copy link
Collaborator

Closes #<ISSUE_NUMBER>

This PR:

This PR does not:

Key places to review:

@bfish713 bfish713 marked this pull request as ready for review November 5, 2024 16:19
@bfish713 bfish713 requested a review from ss-es as a code owner November 5, 2024 16:19
Comment on lines -465 to +466
// Check if the hash is in the cache
if !self.message_cache.read().contains(&message_hash) {
// Add the hash to the cache
self.message_cache.write().put(message_hash, ());

// Check if the hash is in the cache and update the cache
if self.message_cache.write().put(message_hash, ()).is_none() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't profiled this enough to have an opinion on which is faster in most cases, but I'm all for making it more succinct

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not really for speed, it's so that we update the cache on every duplicate message. So if a really old message that's still in the cache comes in we make sure it becomes the most recently used and doesn't fall out of cache.

Copy link
Collaborator

@rob-maron rob-maron Nov 6, 2024

Choose a reason for hiding this comment

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

Ah right this does work better with LRU semantics

@bfish713 bfish713 merged commit 42cf3cc into main Nov 6, 2024
26 checks passed
@bfish713 bfish713 deleted the bf/txns branch November 6, 2024 18:38
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.

4 participants