Takeshi Yoneda
b9571dfbab
compiler: memory usage optimization around br_table (#2251)
This optimizes the memory usage during compilation for
br_table instructions. As you can see in the bench results below,
for some cases where lots of br_tables exists (the case named `zz`),
the compilation uses 10% less allocations and 5% less memory, hence
the slightly faster compilation.
```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
Compilation/wazero-10 2.015 ± 2% 1.993 ± 0% -1.09% (p=0.002 n=6)
Compilation/zig-10 4.200 ± 0% 4.161 ± 1% -0.93% (p=0.004 n=6)
Compilation/zz-10 18.70 ± 0% 18.57 ± 0% -0.69% (p=0.002 n=6)
geomean 5.409 5.360 -0.90%
│ old.txt │ new.txt │
│ B/op │ B/op vs base │
Compilation/wazero-10 297.5Mi ± 0% 287.1Mi ± 0% -3.48% (p=0.002 n=6)
Compilation/zig-10 593.9Mi ± 0% 590.3Mi ± 0% -0.61% (p=0.002 n=6)
Compilation/zz-10 582.6Mi ± 0% 553.7Mi ± 0% -4.96% (p=0.002 n=6)
geomean 468.7Mi 454.4Mi -3.03%
│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
Compilation/wazero-10 457.0k ± 0% 449.1k ± 0% -1.72% (p=0.002 n=6)
Compilation/zig-10 275.8k ± 0% 273.8k ± 0% -0.70% (p=0.002 n=6)
Compilation/zz-10 926.5k ± 0% 830.9k ± 0% -10.32% (p=0.002 n=6)
geomean 488.7k 467.5k -4.35%
```
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>