binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

SmallVector could call constructors only when relevant

Open kripken opened this issue 4 years ago • 3 comments

The fixed storage there is a std::array which constructs the items immediately. We could instead use a different approach that only calls the constructor when the size actually increases.

This looks like it might be a noticeable speedup as I see profile data in which Literals, a SmallVector of Literal, is fairly high. The Literal constructor is apparently not cheap.

kripken avatar Jan 13 '22 21:01 kripken

Here is the benchmark I am looking at:

wasm-ctor-eval --ctors=__wasm_call_ctors,main --kept-exports=main --ignore-external-input a.out.wasm -o b.out.wasm --mvp-features

benchmark.zip

kripken avatar Jan 13 '22 21:01 kripken

The benchmark stresses interpreter performance. That matters for wasm-ctor-eval if you run it on computationally-intensive code. But any speedups there should also help with compile times in general as it will help --precompute too.

kripken avatar Jan 13 '22 21:01 kripken

It would be great if someone wanted to pick this up. It requires some C++ "magic" that I'm not very familiar with (calling a constructor on existing memory, something like that is needed here I assume).

kripken avatar Jan 13 '22 22:01 kripken