perf: mechanism for parallel read/write in mo.persistent_cache#8805
Merged
dmadisetti merged 6 commits intomainfrom Mar 26, 2026
Merged
perf: mechanism for parallel read/write in mo.persistent_cache#8805dmadisetti merged 6 commits intomainfrom
dmadisetti merged 6 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new persistent cache loader (method="lazy") intended to improve mo.persistent_cache performance by parallelizing disk read/write and storing a lightweight manifest for cached values.
Changes:
- Added
LazyLoader(manifest-based persistence + parallel blob loading/writing) and registered it under persistent loader keys. - Introduced msgspec schemas and stubs (
lazy_stub.py) to represent cached items and deferred references. - Adjusted cache/stub behavior (UIElement handling in cache update, FunctionStub metadata/linecache behavior, ModuleStub metadata).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| marimo/_save/loaders/lazy.py | Adds the new LazyLoader implementation and manifest/blob IO behavior. |
| marimo/_save/loaders/init.py | Registers "lazy" as a supported persistent loader key. |
| marimo/_save/stubs/lazy_stub.py | Adds msgspec schemas and a reference stub for lazy cache restoration. |
| marimo/_save/stubs/init.py | Exposes ReferenceStub and adds LAZY_STUB_LOOKUP mapping. |
| marimo/_save/stubs/function_stub.py | Captures filename/lineno metadata and primes linecache for better tracebacks. |
| marimo/_save/stubs/module_stub.py | Extends ModuleStub to carry a hash field. |
| marimo/_save/cache.py | Updates restore/update behavior (notably UIElement storage and ReferenceStub restoration). |
| marimo/_save/save.py | Makes cached-return lookup more defensive (meta.get("return")). |
| marimo/_smoke_tests/cache_lazy_benchmark.py | Adds a benchmark notebook for comparing pickle vs lazy persistence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
for more information, see https://pre-commit.ci
mscolnick
approved these changes
Mar 26, 2026
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.21.2-dev61 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
In response to reported performance issues in
mo.persistent_cache, this PR examines disk serialization in a non-blocking way. The associatedsmoke_testwrites 1GB of memory to disk utilizing the existingPickleStoreand the newLazyStore, which avoids rewrites of existing values and has non-blocking deserialization.