bytecodealliance / lucet

Lucet, the Sandboxing WebAssembly Compiler.
Apache License 2.0
4.06k stars 165 forks source link

why is Lucet slower than wasmtime #607

Closed ZW007 closed 3 years ago

ZW007 commented 4 years ago

Hi! Lucet has a shorter startup time, but why for many heavy tasks, lucet is slower than wasmtime. They both use cranelift for generating machine code from wasm, right?

cfallin commented 4 years ago

That's a good question; more data and investigation on this would certainly be useful! (Though in the medium-to-long term, the plan is to merge Lucet and Wasmtime so it may not matter as much.)

My suspicion is that this has to do with the FuncEnvironment that each compiler plugs into the Cranelift backend -- this allows a user of Cranelift to customize the code sequences for certain operations, such as heap accesses or function calls. So perhaps the differences in those sequences or the data structures that they access account for some of the performance delta. But this could use more study!

tschneidereit commented 4 years ago

@ZW007 while as Chris says in the long term this might matter less, I think it'd be great to find the source of the difference nevertheless. Do you by any chance have code you could share that shows this difference in performance?

ZW007 commented 4 years ago

@tschneidereit Hi Till. I tested several. For example, a matrix task that takes seconds to finish

jedisct1 commented 3 years ago

Lucet is slow with the default settings.

Adding --reserved-size "4GiB" to the lucetc-wasi command immediately makes its performance match wasmtime's.