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 merkledb caches to be size based #1947

Merged
merged 6 commits into from
Aug 30, 2023
Merged

Conversation

StephenButtolph
Copy link
Contributor

Why this should be merged

Allows slightly more fine-grained cache size tuning. Specifically useful for the value caches whose entry size can very significantly.

How this works

LRU -> SizedLRU

How this was tested

updated the tests

x/merkledb/db.go Outdated
@@ -31,7 +31,7 @@ import (
)

const (
DefaultEvictionBatchSize = 100
DefaultEvictionBatchSize = 256 * units.KiB
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we may want bigger than this?

Choose a reason for hiding this comment

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

This is just the default used in getStandaloneTrieView which is only used in proof verification

Choose a reason for hiding this comment

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

That said we can make it bigger. 1 MiB?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking 1MB is a good place to start.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why would we want larger than this? This isn't a cache - this size that is used to evict from the cache... As dan said - this is only used (internally) for writing during proof verification... which is writing into a memdb

Choose a reason for hiding this comment

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

welp I already changed it to 1 MiB. In any case I don't think it matters much. I also unexported it since this is only used in this package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More I think about this - I think the value should be 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the verification cache sizes and eviction batch size.

}

errs.Add(c.onEviction(key, value))
errs.Add(c.onEviction(k, v))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to exit on the first error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just keeping with the prior semantics here

@StephenButtolph StephenButtolph merged commit 3811802 into dev Aug 30, 2023
16 checks passed
@StephenButtolph StephenButtolph deleted the size-based-caching branch August 30, 2023 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants