leaningtech / cheerp-meta

Cheerp - a C/C++ compiler for Web applications - compiles to WebAssembly and JavaScript
https://labs.leaningtech.com/cheerp
Other
1.02k stars 50 forks source link

Insights into performance of tail calls. #154

Closed yurydelendik closed 1 year ago

yurydelendik commented 1 year ago

I'm trying to follow up on the following articles:

Currently, Firefox/SpiderMonkey landed Wasm tail calls patches. And I was pleased to see https://webvm.io/ works (it loads/runs different cxcore.wasm), but cannot find any details on why tail calls are important for performance of x86 virtualization. More specifically, there is a need to construct simple benchmarks for this specific use case. Can you provide couple of pointers on how to build these?

Running webvm in Firefox Nightly with tail calls enabled/disabled I see about the same numbers by running time python3 examples/python3/fibonacci.py. Am I doing it wrong?

Thank you.

alexp-sssup commented 1 year ago

Tails calls are important to efficiently implement indirect jumps, we wrote an extensive write up on the matter that you might have missed.

https://leaningtech.com/blog/2020/06/16/extreme-webassembly-1-pushing-browsers-to-their-absolute-limits/

Since the time the blog post was written we have implemented quite a few improvements in CheerpX that mitigate the impact though, in particular we figured out a technique to make the indirect jump on library calls less of a problem.

Closing since this repository is about Cheerp (C++ to WebAssembly/JavaScript compiler), not about CheerpX (x86 on Wasm VM and JIT). For further discussion consider joining our discord: https://discord.gg/yTNZgySKGa