feat(depot-client): wire sqlite optimization flags#4923
feat(depot-client): wire sqlite optimization flags#4923NathanFlurry wants to merge 1 commit intographite-base/4923from
Conversation
Code Review: feat(depot-client): wire sqlite optimization flagsOverviewThis PR wires the existing
Issues1. Possible logic bug in The early-return guard falls back to fetching only page 1 if if !config.startup_preload_first_pages
|| !config.preload_hints_on_open // suspicious
|| !config.page_cache_mode.caches_startup_preloaded_pages()
|| config.startup_preload_max_bytes < DEFAULT_PAGE_SIZE
{
return fetch_initial_main_page_for_registration(...)
2. Write lock held during page-cache insertion after transport call (vfs.rs) Previously: let page_cache = { self.state.read().page_cache.clone() }; // clone arc, drop lock
for fetched in ok.pages {
page_cache.insert(...); // moka: &self, no exclusive lock needed
}Now: let mut state = self.state.write(); // exclusive lock held for all inserts
for fetched in ok.pages { state.cache_page(...); }The write lock is necessary because 3. page_cache_weighted_size: state
.page_cache
.weighted_size()
.saturating_add(state.protected_page_cache.len() as u64),Without a custom moka weigher, 4. O(n^2) deduplication for early-page hints (vfs.rs) for pgno in 1..=early_page_count {
if !snapshot.ranges.iter().any(|range| range.contains(pgno))
&& !snapshot.pgnos.contains(&pgno) // Vec::contains is O(n)
{
snapshot.pgnos.push(pgno);
}
}
snapshot.pgnos.sort_unstable();
5. Minor: .map(|mut pages| pages.drain(..).find(|(pgno, _)| *pgno == 1).map(|(_, bytes)| bytes))Prefer Positive observations
SummaryThe two concerns worth resolving before merge are: (1) the spurious |
2b8b055 to
48cc3bb
Compare
5a35d47 to
9155543
Compare
48cc3bb to
7835a88
Compare
9155543 to
e5462a4
Compare
7835a88 to
cb7241f
Compare
e5462a4 to
8702157
Compare
|
Landed in main via stack-merge fast-forward push. Commits are in main; closing to match. |

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: