8000 perf: skip page cache allocation for in-memory databases by adityamukho · Pull Request #341 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

perf: skip page cache allocation for in-memory databases - #341

Merged
adityamukho merged 1 commit into
mainfrom
274-inmemory-page-cache
Aug 23, 2026
Merged

adityamukho merged 1 commit into
mainfrom
274-inmemory-page-cache

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Summary

  • MemoryBackend serves every read/write directly from RAM and never consults the page cache, so Minigraf::in_memory_with_options was pointlessly honoring OpenOptions::page_cache_size when constructing PersistentFactStorage.
  • In-memory databases now always allocate the PageCache with zero capacity, via a new memory_page_cache_capacity() helper, regardless of what page_cache_size was set to.
  • OpenOptions::page_cache_size (field and builder method) and Minigraf::in_memory_with_options are now documented as file-backed-only.
  • Added pub(crate) test-only accessors (PageCache::capacity(), PersistentFactStorage::page_cache_capacity()) to verify the wiring end-to-end.

This is a safe, no-op change with no semantic impact on query results — MemoryBackend never exercises the page-cache code path.

Closes #274

Test plan

  • New test db::tests::test_in_memory_page_cache_size_ignored (watched RED before implementing, then GREEN)
  • New test persistent_facts::tests::test_page_cache_capacity_reflects_constructed_value
  • cargo test — 681 unit tests + all integration/doc tests pass
  • cargo clippy --all-features -- -D warnings — clean
  • cargo fmt --check — clean
  • Confirmed no changes to src/browser/mod.rs (separate issue perf: skip page cache allocation for BrowserDb (WASM/IndexedDB backend) #275)

🤖 Generated with Claude Code

https://claude.ai/code/session_01YMWSutMLJJ7Y5b8hs9ZaCU

@codecov
codecov Bot commented Aug 23, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

MemoryBackend serves every read and write directly from RAM and never
consults the page cache, so honoring OpenOptions::page_cache_size for
in_memory_with_options was pointless. Always construct the PageCache
with zero capacity for MemoryBackend-backed storage, and document
page_cache_size as file-backed-only.

Adds pub(crate) capacity() / page_cache_capacity() test accessors on
PageCache / PersistentFactStorage to verify the wiring.

Closes #274

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YMWSutMLJJ7Y5b8hs9ZaCU
@adityamukho
adityamukho force-pushed the 274-inmemory-page-cache branch from dbb0c6f to 33423fa Compare August 23, 2026 17:08
@adityamukho
adityamukho merged commit 797fb30 into main Aug 23, 2026
17 checks passed
@adityamukho
adityamukho deleted the 274-inmemory-page-cache branch August 23, 2026 17:15
adityamukho added a commit that referenced this pull request Oct 7, 2026
…the IndexedDB flush (#470)

checkpoint(), importGraph() and every write collected dirty pages with
read_page_raw(id).ok() in a filter_map, so a page that failed to read
was silently left out of the flush to IndexedDB while the call reported
success. A shared take_dirty_pages helper (the same one v3 has since
#469) now returns the read error.

No current path leaves a dirty id without a page (ids enter the dirty
set only after the page is stored), so this is defensive rather than a
fix for observed loss.

The browser unit tests did not compile on wasm32 (a duplicate
page_cache_capacity from #341/#342, and dir_sync tests using tempfile);
both are fixed so the two new regression tests run.


Claude-Session: https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

perf: skip page cache allocation for in-memory databases

1 participant

0