fix(protocol/sandbox): restore Wasmtime module LRU cache#5525
Conversation
fca11ab to
1ea3dd2
Compare
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request restores an in-memory module cache mechanism previously lost during the migration from Wasmer to Wasmtime. By caching compiled Wasmtime modules, the system avoids repeated compilation for previously encountered Wasm modules, improving performance across various components of the Gear node. The changes include the creation of a dedicated caching crate and its integration into the relevant execution paths, alongside benchmarking to validate the performance impact. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ea3dd2664
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Code Review
This pull request introduces a new crate, gear-wasmtime-cache, which implements an in-memory LRU cache for compiled Wasmtime modules. This cache is integrated across various executors, sandboxes, and tools to reduce compilation overhead. Feedback on the implementation highlights a severe concurrency bottleneck in get_impl where the global mutex lock is held during the slow compilation step (Module::new). It is recommended to release the lock before compiling and re-acquire it when inserting the compiled module into the cache.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17f389fc47
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Closes #
Summary
Restore the in-memory module cache that was lost during #4860. The old gear-wasmer-cache behavior avoided repeated compilation for already-seen wasm modules; this PR adds the equivalent shared cache for Wasmtime module creation paths.
The change wires the cache into sandbox host, embedded executor, ethexe processor, lazy-pages fuzzer, and calc-stack-height, and adds a Criterion benchmark comparing Wasmtime disk cache lookup with the in-memory LRU path.
How to test
Notes
No breaking changes. The benchmark uses sdk/examples/big-wasm/big.wasm as the repeated module input.
Checklist