I'm wondering what is current state of the art of Substrate's pallet-contracts performance as compared to the same functional implementation as a pallet.

I acknowledge that different logic can have different cost, but it would still be useful to know if it is 2x inherently slower, 10x, 100x... It would help others to make a decision whether this is definitely not acceptable overhead or something that can be considered.

Specifically I'm curious about the cost without gas metering enabled, to get a sense of the baseline. Roughly the cost of running wasmi on top of wasmtime rather than natively, but I wasn't able to find benchmarks of those either.

1 Answer 1


Smart contracts via pallet-contracts are run using a Wasm interpreter, namely wasmi, while native pallets are run via Wasm JIT, namely Wasmtime, (or native).

Therefore the underlying question is: What is the performance difference between the wasmi interpreter and the Wasmtime JIT or native code.

For this I collected some benchmarks in the past using Coremark utilities. The scores can be used as a linear comparison of performance. They are depending on the system the tests ran on but allow for comparison if run on the same platform.

The scores indicate the following relations:

  • wasmi is roughly 1.6% the performance of native code
  • wasm3, the fastest known Wasm interpreter is roughly 8% the performance of native code.
  • Wasmtime JIT is roughly 50% of the performance of native code.

We are currently working on speeding up our wasmi interpreter but there are no results, yet. The wasm3 performance is quite impressive for an interpreter and we will probably not surpass it but hopefully come close to it.

There is also work done to use Wasmer singlepass as another execution engine for pallet-contracts which is roughly 50% the performance of Wasmtime and therefore ~25% of native code. However, this work is very experimental as of now.

  • As I mentioned in initial question, I don't think it is just wasmi vs wasmtime, it is wasmi under wasmtime specifically, so baseline is not 100% of native for it, but 50% of wasmtime itself. Not sure if wasmi performance should be roughly halved in that case or is there anything else that causes even more overhead.
    – nazar-pc
    Commented Mar 31, 2022 at 18:50
  • BTW, there is work ongoing for enabling wasmer singlepass, which is much faster than interpreters and still not susceptible for JIT bombs, but that is a future, not present.
    – nazar-pc
    Commented Mar 31, 2022 at 19:07
  • Wasmer singlepass integration is experimental. The tradeoff between Wasmer singlepass and wasmi ist not only the Wasm execution performance but also the compilation performance. The compilation performance of the Wasm runtime is especially important since smart contracts usually are very tiny scripts that do not compute a lot due to gas costs. Therefore costs of compilation is significant. In past experiments we found that the compilation overhead of Wasmer singlepass is 30% higher than with wasmi.
    – Robin
    Commented Apr 1, 2022 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.