-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
||
// 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; |
There was a problem hiding this comment.
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>, |
There was a problem hiding this comment.
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?
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.