-
Notifications
You must be signed in to change notification settings - Fork 11
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
Benchmarks with Wasmtime 0.22.1-preview1 #12
Comments
It looks like your It seems like either Note that setting the memory minimum to 3 "fixes" the issue because now the writes are no longer out-of-bounds. I'll keep investigating. |
Actually, I take that back. The writes appear in bounds. Still digging as to the problem. |
There's clearly some memory corruption taking place as I saw it manifest as this panic during one of the benchmark runs:
|
Funny thing is that the sample hasn't changed since the very start of the project - only recompiled with newer versions of OPA. And we already had one memory issue with that quite a bit back. Seems that the benchmark once again tripped something. |
Current theory: the problem is the finalizer thread is corrupting some reference counters (internal to Wasmtime), causing premature frees and other unpleasantness. Right now there are function handles (from What I believe is happening is that, due to a race with the finalizer thread, the reference count of When an instance is deallocated while still in use, all sorts of unpleasantness follows as the Unfortunately, the underlying C API has thread-affinity for objects associated with a store. So this leaves us in a bind for .NET as we must either:
For now you should be able to work around the problem by calling I also noticed that |
I've opened bytecodealliance/wasmtime-dotnet#53 to track the underlying issue here. |
Oh, so I totally misunderstood DefineFunction API (I thought define it and everything's fine forever)... now if the return is Disposable... does that mean after my BuildHost() method is complete, the defined function is gone too? Would I need to hold on to those Disposable until Dispose()? Or if I Dispose them right away, the definition is still there? |
Thanks for catching the missing Dispose()! |
Everything is reference counted internally, so you don't need to keep the |
https://github.com/christophwille/csharp-opa-wasm/blob/master/src/Opa.Wasm.Benchmarks/Program.cs
Times went up, and I got a so far non-reproducible error (it happens sometimes, but not every time, eg just now I had it happen in WorkloadWarmup):
WorkloadActual 24: 128 op, 624120800.00 ns, 4.8759 ms/op
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Wasmtime.Interop.wasm_memory_delete(IntPtr)
at Wasmtime.Interop.wasm_memory_delete(IntPtr)
at Wasmtime.Interop+MemoryHandle.ReleaseHandle()
at System.Runtime.InteropServices.SafeHandle.InternalRelease(Boolean)
at System.Runtime.InteropServices.SafeHandle.Finalize()
ExitCode != 0
// Benchmark Process 28328 has exited with code -1073741819
@peterhuene any ideas?
The text was updated successfully, but these errors were encountered: