Open warappa opened 1 year ago
I've observed that this is not only caused by too many invocations, but also by too much data transfer. By limiting to only 1 invocation, using the following code I manually binary searched the maximum amount of bytes I could return.
I cause the same error by either: Incrementing that amount by 1; Or the sum of multiple invocations exceeds that number.
WasiConfiguration wasiConfiguration = new WasiConfiguration().WithInheritedStandardOutput().WithInheritedStandardError();
using var host = new IsolatedRuntimeHost().WithAssemblyLoader(LoadAssembly);
using var isolatedRuntime = new IsolatedRuntime(host);
// Maximum bytes without crash: 0b0111_0110_0100_1010_1110_0011 = 7752419 = 7.39 MiB
const int bytesToGenerate = 0b0111_0110_0100_1010_1110_0011;
IsolatedObject byteGenerator = isolatedRuntime.CreateObject<ReturnManyPseudoRandomByteGenerator>();
byteGenerator.Invoke<int, int, byte[]>("GenerateBytes", 1, bytesToGenerate);
class ReturnManyPseudoRandomByteGenerator {
public byte[] GenerateBytes(int seed, int count) {
Random random = new(seed);
byte[] bytes = new byte[count];
random.NextBytes(bytes);
return bytes;
}
}
Setup
I wanted to try out the limits of DotNetIsolator and changed the
ConsoleSample.Program.cs
file to have callruntime.Invoke(...)
many more times (because you don't know how often a 3rd party code would callInvoke(...)
). I also emptied the lambda body to speed up the invocation and to not have parameters, captured variables or return values have any influence.Any non-empty lambda body causes the error to happen at an even lower invocation count.
Issue
Up to
35317
invocations there is no problem: The final output of the host is printed in the console (with impressive 0,04ms/call!).But when incrementing
numCalls
by just1
to35318
, it breaks with aWasmtimeException
(see below).Maybe this is an issue of Wasmtime itself, but I'm not sure as I'm not experienced in this kind of magic 😉.
Edited ConsoleSample
Raised Exception
Expected Result
There should be no upper limit in invocation count.
Additional Information
Tested on 6dbe1a3b1890beea8a375d854ffe00784fa147dd This error also happened on previous versions of DotNetIsolator.
Personal Note
That's some awesome stuff your doing here! Please keep it on!