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

refactor(page_cache): introduce a sub-cache for merkle pages below a fixed depth #800

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

rphmeier
Copy link
Contributor

This puts all pages with level <= 3 into a "fixed level cache" hash-map.
Cache eviction will never remove these pages and they can only be removed if the page itself is deleted.

This will be followed up by a PR for prepopulation.


// Total number of nodes stored in one Page. It depends on the `DEPTH`
// of the rootless sub-binary tree stored in a page following this formula:
// (2^(DEPTH + 1)) - 2
pub const NODES_PER_PAGE: usize = (1 << DEPTH + 1) - 2;

// The fixed number of levels we always preserve in-memory.
const FIXED_LEVELS: usize = 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is slightly wrong.

If the root is the 0th level, we still keep 1st, 2nd and the 3rd levels. So the number that figures in the constant is 3 but we keep 4 levels.

@@ -146,11 +149,50 @@ struct CacheShard {
}

struct CacheShardLocked {
// storage for pages in the levels of the tree which we always cache.
fixed_level_cache: HashMap<PageId, CacheEntry, FxBuildHasher>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: "Fixed" is ok, but I wonder if something like pinned would be slightly better?

Copy link
Contributor

pepyakin commented Feb 12, 2025

Merge activity

  • Feb 12, 3:48 AM EST: A user started a stack merge that includes this pull request via Graphite.
  • Feb 12, 3:49 AM EST: A user merged this pull request with Graphite.

@pepyakin pepyakin merged commit b374009 into master Feb 12, 2025
8 checks passed
@pepyakin pepyakin deleted the rh-fixed-level-cache branch February 12, 2025 08:49
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.

2 participants