theodm
theodm
CCConvex Community
Created by theodm on 11/10/2023 in #support-community
WASM support on V8 runtime / node.js
I can confirm it is a bug in the building process of the glue code. wasm-bindgen generate the following glue code:
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
which make log statements undefined in convex dashboard. But replacing to
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;

const array = new Uint8Array(getUint8Memory0().subarray(ptr, ptr + len));

return cachedTextDecoder.decode(array);
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;

const array = new Uint8Array(getUint8Memory0().subarray(ptr, ptr + len));

return cachedTextDecoder.decode(array);
}
makes log statements ok. esbuild-plugin-wasm could be a great addon, otherwise I will edit my own glue code. Concerning running time, I was speaking about the one we can see from convex dashboard (the global function running time), did some new tests this morning and all were under 1000ms. The actual rust code take 52ms to execute from wasm in all run but the action that take the most time is let file = await request.arrayBuffer(); which took between 500ms to 800ms depending on runs, that body is in fact a 4MB binary file so not a very big one. That might be due to the client latency to send the whole file to the server ? Depending on the location of the servers, that seems pretty big to me: I am testing from Paris, France using a 1 Gbps connection.
16 replies
CCConvex Community
Created by theodm on 11/10/2023 in #support-community
WASM support on V8 runtime / node.js
Thanks for your answer. I did some experiments on V8 runtime and I can say it is partly working. I used glue code generated using wasm-pack (target web, I tried with target bundler and didn’t work saying is malloc is undefined). First thing: I binded console.log to use it in Rust but all my log statements in the console appears as « undefined », when I test the same glue code locally on chrome every log statements are fine. I got big discrepancies concerning running times, from 1299ms to 6650ms, for the same input. Away of that, the actual rust code seems to work great, but not having console output is a pretty big downside.
16 replies