Canister install failed for threads or shared memory

I install wasm in DFX occure thread and shared memory issue.

The returned message is as following:

:~/icp/examples/fio$ dfx canister install fio
Installing code for canister fio, with canister_id rrkah-fqaaa-aaaaa-aaaaq-cai
The invocation to the wallet call forward method failed with the error: An error happened during the call: 5:
Wasm module of canister rrkah-fqaaa-aaaaa-aaaaq-cai is not valid: Wasmtime failed to validate wasm module wasmtime::Module::validate() failed with threads support is not enabled (at offset 17632)


Another Error:
$ dfx canister install decoder
Installing code for canister decoder, with canister_id rrkah-fqaaa-aaaaa-aaaaq-cai
The invocation to the wallet call forward method failed with the error: An error happened during the call: 5:
Wasm module of canister rrkah-fqaaa-aaaaa-aaaaq-cai is not valid: Wasmtime failed to validate wasm module wasmtime::Module::validate() failed with threads must be enabled for shared memories (at offset 2342)

1 Like

Threads and shared memory have not yet been officially adopted by the Wasm standard, and hence are not supported on the IC.

Furthermore, it is not clear whether they can ever be supported on the IC, since the non-determinism inherent to proper threads is fundamentally incompatible with deterministic execution as needed for consensus on a block chain.

2 Likes

Thanks for your reply.
I found the restrict in Wasmtime as following:

Could we implement the multi-thread by multi-canistors or something others?
And wait for more info from IC.
Thanks.

Not in a way that would even be remotely efficient. Threads are all about fast shared-memory concurrency, whereas canisters provide shared-nothing concurrency. Emulating shared memory with messaging would be so slow that it would defeat the purpose. Among many other problems.

Since IC canister is single-threaded, if a canister needs a huge mount of computing resources, how can a single canister maximize the use of a large number of CPUs on the IC network?

The IC may execute multiple canisters in different threads when it can (though I don’t think it’s doing that yet). So you could potentially use multiple canisters for parallelisation. But you have to live with this being shared-nothing concurrency.

So compared to a conventional OS, you only have multiple processes but not multiple threads.

In general, I’d say that the IC is not the platform you want to do heavy number crunching on, at least not for the time being. The per-message cycle limit alone makes that difficult at the moment. And replication makes it pretty wasteful, too.

1 Like

Thanks a lot for your reply.
I have found the roadmap of multi-threads in WebAssembly, and also I found the latest update of WasmEdge.

Could you share the roadmap of threads in DFinity?
The multi-thread and heavy number crunching is the base core of our project.

Dear Rossberg,
What’s your suggestion about our project on IC network?

There is no IC roadmap that contains threads. It’s a completely open problem if and how they could be supported.

Consequently, I’m afraid I don’t have any good suggestion for you, other than removing the dependency on threads (which I know may not be easy).

PS: I don’t know much about WasmEdge, but it is not related to the IC.

Thanks for your info.

We will study the wasmtime_embedder in the IC to find some solutions.