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

Introduce a module cache abstraction #3841

Merged
merged 18 commits into from
May 8, 2023
Merged

Introduce a module cache abstraction #3841

merged 18 commits into from
May 8, 2023

Conversation

Michael-F-Bryan
Copy link
Contributor

@Michael-F-Bryan Michael-F-Bryan commented May 3, 2023

This PR adds an abstraction for caching modules to the WasiRuntime, plus some implementations that can be composed to implement tiered module caching.

TL;DR:

  • Introduce a CompiledModuleCache trait that has async save() and load() methods
    • Both methods accept a &dyn VirtualTaskManager at the moment in case we need to spawn blocking operations, but that'll probably be moved around
  • Add a and_then() combinator to CompiledModuleCache so you can layer your caching
  • I've taken the three different layers of caching in ModuleCache and split them into their own types - ThreadLocalCache, SharedCache, and OnDiskCache
  • There is a wasmer_wasix::runtime::module_cache::default_cache() constructor which chains the thread-local, Arc<RwLock<HashMap>>, and on-disk caches together
  • The ModuleCache is now just a wrapper around an instance of that default cache

CC: #3603 and #3831.

@Michael-F-Bryan Michael-F-Bryan changed the base branch from master to resolver-abstraction May 3, 2023 07:29
@Michael-F-Bryan Michael-F-Bryan force-pushed the resolver-abstraction branch from fbb72ab to d2862f2 Compare May 3, 2023 14:28
@Michael-F-Bryan Michael-F-Bryan force-pushed the resolver-abstraction branch from d2862f2 to 2f83b25 Compare May 4, 2023 08:35
Base automatically changed from resolver-abstraction to master May 4, 2023 10:36
@Michael-F-Bryan Michael-F-Bryan marked this pull request as ready for review May 5, 2023 04:03
lib/wasi/src/runtime/module_cache/mod.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/types.rs Outdated Show resolved Hide resolved
@Michael-F-Bryan Michael-F-Bryan enabled auto-merge May 5, 2023 05:57
lib/wasi/src/runtime/module_cache/disabled.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/mod.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/mod.rs Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/on_disk.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/on_disk.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/on_disk.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/types.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/types.rs Outdated Show resolved Hide resolved
lib/wasi/src/bin_factory/exec.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/types.rs Show resolved Hide resolved
@Michael-F-Bryan Michael-F-Bryan disabled auto-merge May 8, 2023 07:33
lib/wasi/src/runtime/module_cache/types.rs Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/types.rs Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/types.rs Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/types.rs Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/types.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/filesystem.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/mod.rs Show resolved Hide resolved
lib/cli/src/commands/run_unstable.rs Show resolved Hide resolved
@Michael-F-Bryan Michael-F-Bryan enabled auto-merge May 8, 2023 08:55
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.

3 participants