Comments (8)
ah I see, we stumbled upon this behavior while solving a different issue. In this case it is safer to Compile
separately than Instantiate
ing, this way the flag closeWithModule
won't be set implicitly
from wazero.
When an in-memory cache is configured, compilation does not actually occur for real, even though we do invoke compileModule
internally.
Lines 137 to 142 in 350e81e
What really happens is that if there is a hit at getCompiledModuleFromMemory()
then we return early with the pre-compiled module.
e.g. see
wazero/internal/engine/wazevo/engine_cache.go
Lines 46 to 50 in 1b2fd85
you can verify this easily if you try to compile a large module (which would take a sensible time compiling twice)
from wazero.
@evacchi , @mathetake - As explained in the description - problem is observed when running the same module twice, using two runtime instances that share an in-memory cache. The module is then compiled every single time and no caching occurs.
This, to me, is a bug. Considering the already referenced comment - this is not the desired behavior too.
from wazero.
Did you share a reproducer for this one?
from wazero.
@ncruces, @evacchi, @mathetake - after a bit of play with the debugger - I've come across the root cause for the problem. When using Instantiate
or InstantiateWithConfig
(implicit module compilation) - the flag closeWithModule
on the compiled module is being raised. As a result of that - after module instantiation is complete - the compiled module is being closed (hence removed from the in-memory cache).
One can say - this is a problem with the documentation and yes - docs would definitely appreciate a bit of love here. However - considering that caching is at play - my honest suggestion is that the flag closeWithModule
should only be respected if no cache instance is configured for the said runtime. This will unify behaviors with the FS based cache where regardless of the closeWithModule
flag cached entries can be recovered (from disk) and re-compilation avoided.
from wazero.
@evacchi - this behavior is both inconsistent & poorly documented. My humble proposal still stands - closeWithModule
should only happen when no cache is configured for the runtime.
from wazero.
I do not disagree, but meanwhile my suggestion should help you address the shortcoming without having to wait for an update
from wazero.
@evacchi - thank you!
from wazero.
Related Issues (20)
- Plans to support component model? HOT 4
- wasm debug build crashes HOT 9
- performance issue in browser environment HOT 3
- [help want] the program is hangup when read my net file system HOT 1
- [Question] Compilation cache over different versions HOT 1
- `unreachable` error and stack trace if compiled and extra memory, not otherwise HOT 4
- Clarification on concurrency semantics for invocations HOT 2
- `path_open` with an empty path should fail
- `path_symlink` doesn't work HOT 1
- flaky test: TestEngine_sortedCompiledModules
- Should not be able to open a directory with write
- Path normalization causes more accepted file paths HOT 2
- [Question] How to resolve these imports required by wasm runtime HOT 4
- Panic when calling `ExportedFunction` with WASI function name HOT 1
- flaky test: BenchmarkLibsodium/box_seal HOT 9
- Representative benchmarks of wazero for Go compiler perf measurement HOT 9
- Data race in Memory.Grow with concurrency HOT 1
- Standard `os` package test for Go 1.23rc1 is failing on Windows HOT 3
- WASI Preview 2 support HOT 4
- How to use HostFunctionBuilder with multiple goroutines? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wazero.