Commit Graph

1839 Commits

Author SHA1 Message Date
earayu
0fa14a686a Add wazero user: wescale (#2239)
Signed-off-by: earayu <earayu@163.com>
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
Co-authored-by: Nuno Cruces <ncruces@users.noreply.github.com>
2024-06-11 14:02:46 +01:00
Takeshi Yoneda
507493b436 ssa: optimizes findValue function (#2245)
This removes the unnecessary search and addition of block params.
As a result, the compilation gets faster up to 30% while having no
impacts on the runtime performance.

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-10 12:48:20 -07:00
Takeshi Yoneda
5c8366f8d5 ssa: optimizes slice allocations (#2242)
This makes the compilation faster and use less memory:

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
                      │  old.txt   │             new.txt              │
                      │   sec/op   │   sec/op    vs base              │
Compilation/wazero-10   2.184 ± 0%   2.110 ± 0%  -3.40% (p=0.001 n=7)
Compilation/zig-10      4.331 ± 1%   4.187 ± 1%  -3.31% (p=0.001 n=7)
geomean                 3.075        2.972       -3.36%

                      │   old.txt    │               new.txt               │
                      │     B/op     │     B/op      vs base               │
Compilation/wazero-10   337.3Mi ± 0%   301.9Mi ± 0%  -10.49% (p=0.001 n=7)
Compilation/zig-10      599.3Mi ± 0%   594.3Mi ± 0%   -0.84% (p=0.001 n=7)
geomean                 449.6Mi        423.6Mi        -5.79%

                      │   old.txt   │              new.txt               │
                      │  allocs/op  │  allocs/op   vs base               │
Compilation/wazero-10   592.9k ± 0%   527.9k ± 0%  -10.97% (p=0.001 n=7)
Compilation/zig-10      287.8k ± 0%   278.6k ± 0%   -3.20% (p=0.001 n=7)
geomean                 413.1k        383.5k        -7.17%
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-10 08:25:29 -07:00
Takeshi Yoneda
d059981bc4 Fixes flaky TestEngine_sortedCompiledModules (#2241)
fixes #2234

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-09 08:49:14 -07:00
Takeshi Yoneda
56e2a43ae9 regalloc: removes map from RegAllocFunction (#2240)
This improves the compilation slightly as below:

###  wazero compiled as a wasip1
```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
               │ old_zig.txt │           new_zig.txt            │
               │   sec/op    │   sec/op    vs base              │
Compilation-10    2.227 ± 0%   2.184 ± 1%  -1.96% (p=0.001 n=7)

               │ old_zig.txt  │            new_zig.txt             │
               │     B/op     │     B/op      vs base              │
Compilation-10   337.2Mi ± 0%   337.3Mi ± 0%  +0.02% (p=0.001 n=7)

               │ old_zig.txt │            new_zig.txt            │
               │  allocs/op  │  allocs/op   vs base              │
Compilation-10   593.5k ± 0%   592.9k ± 0%  -0.10% (p=0.001 n=7)
```

### Zig stdlib

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
               │  old.txt   │             new.txt              │
               │   sec/op   │   sec/op    vs base              │
Compilation-10   4.371 ± 1%   4.329 ± 0%  -0.96% (p=0.001 n=7)

               │   old.txt    │              new.txt               │
               │     B/op     │     B/op      vs base              │
Compilation-10   599.3Mi ± 0%   599.3Mi ± 0%  -0.00% (p=0.002 n=7)

               │   old.txt   │           new.txt            │
               │  allocs/op  │  allocs/op   vs base         │
Compilation-10   287.9k ± 0%   287.9k ± 0%  ~ (p=0.053 n=7)
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-08 09:51:42 -07:00
syumai
981e71dba6 fix typo in the cache example test function name (#2238)
Signed-off-by: Shuichiro Fukuoka <syumai@gmail.com>
2024-06-08 08:04:21 +01:00
Takeshi Yoneda
99953679fd regalloc: removes unnecessary Instruction.Uses (#2237)
This also early stops resetting IDedPool.

### Zig stdlib

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
               │ old_zig.txt │           new_zig.txt            │
               │   sec/op    │   sec/op    vs base              │
Compilation-10    4.540 ± 0%   4.380 ± 1%  -3.51% (p=0.001 n=7)

               │ old_zig.txt  │          new_zig.txt          │
               │     B/op     │     B/op      vs base         │
Compilation-10   599.3Mi ± 0%   599.3Mi ± 0%  ~ (p=0.383 n=7)

               │ old_zig.txt │         new_zig.txt          │
               │  allocs/op  │  allocs/op   vs base         │
Compilation-10   288.0k ± 0%   288.0k ± 0%  ~ (p=0.805 n=7)
```

### wazero compiled as a wasip1 binary

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
               │  old.txt   │             new.txt              │
               │   sec/op   │   sec/op    vs base              │
Compilation-10   2.264 ± 1%   2.224 ± 0%  -1.80% (p=0.001 n=7)

               │   old.txt    │            new.txt            │
               │     B/op     │     B/op      vs base         │
Compilation-10   337.3Mi ± 0%   337.3Mi ± 0%  ~ (p=0.318 n=7)

               │   old.txt   │           new.txt            │
               │  allocs/op  │  allocs/op   vs base         │
Compilation-10   593.7k ± 0%   593.6k ± 0%  ~ (p=0.456 n=7)
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-07 14:03:39 -07:00
Takeshi Yoneda
0649820fb9 Removes non-static locals collection (#2236)
This stops gathering `NonStaticLocals` during validation phase,
which was previously used to do the "fast pass" on variable search
by the frontend. However, it had no impact after the last mile refactoring
included in 1.7.0 and caused tons of allocations.

As as result, you can see the compilation perf improvements especially
around memory pressure without any impacts on the runtime perf

### Zig 
```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/stdlibs
                             │ old_zig.txt │           new_zig.txt            │
                             │   sec/op    │   sec/op    vs base              │
Zig/Compile/test-opt.wasm-10    3.769 ± 1%   3.761 ± 1%       ~ (p=0.485 n=6)
Zig/Run/test-opt.wasm-10        18.78 ± 1%   18.74 ± 0%  -0.21% (p=0.041 n=6)
Zig/Compile/test.wasm-10        4.677 ± 1%   4.515 ± 0%  -3.48% (p=0.002 n=6)
Zig/Run/test.wasm-10            19.31 ± 1%   19.27 ± 1%       ~ (p=1.000 n=6)
geomean                         8.942        8.850       -1.04%

                             │ old_zig.txt  │            new_zig.txt             │
                             │     B/op     │     B/op      vs base              │
Zig/Compile/test-opt.wasm-10   394.7Mi ± 0%   393.5Mi ± 0%  -0.30% (p=0.002 n=6)
Zig/Run/test-opt.wasm-10       741.7Mi ± 0%   741.7Mi ± 0%       ~ (p=0.621 n=6)
Zig/Compile/test.wasm-10       659.5Mi ± 0%   599.3Mi ± 0%  -9.12% (p=0.002 n=6)
Zig/Run/test.wasm-10           1.296Gi ± 0%   1.296Gi ± 0%       ~ (p=0.102 n=6)
geomean                        711.5Mi        694.2Mi       -2.44%

                             │ old_zig.txt │            new_zig.txt             │
                             │  allocs/op  │  allocs/op   vs base               │
Zig/Compile/test-opt.wasm-10   362.6k ± 0%   343.2k ± 0%   -5.34% (p=0.002 n=6)
Zig/Run/test-opt.wasm-10       51.58k ± 0%   51.58k ± 0%        ~ (p=0.978 n=6)
Zig/Compile/test.wasm-10       514.7k ± 0%   288.1k ± 0%  -44.04% (p=0.002 n=6)
Zig/Run/test.wasm-10           2.156M ± 0%   2.156M ± 0%        ~ (p=0.273 n=6)
geomean                        379.5k        323.8k       -14.69%
```

### TinyGo
```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/stdlibs
                                      │ old_tinygo.txt │            new_tinygo.txt             │
                                      │     sec/op     │    sec/op      vs base                │
TinyGo/Compile/container_heap.test-10    410.8m ± 1%     399.8m ± 0%    -2.69% (p=0.001 n=7)
TinyGo/Run/container_heap.test-10        14.41m ± 0%     14.29m ± 2%    -0.77% (p=0.026 n=7)
TinyGo/Compile/container_list.test-10    410.5m ± 1%     398.1m ± 0%    -3.02% (p=0.001 n=7)
TinyGo/Run/container_list.test-10        14.27m ± 2%     14.16m ± 1%         ~ (p=0.073 n=7)
TinyGo/Compile/container_ring.test-10    403.7m ± 1%     392.5m ± 2%    -2.77% (p=0.001 n=7)
TinyGo/Run/container_ring.test-10        14.24m ± 0%     14.27m ± 1%         ~ (p=0.259 n=7)
TinyGo/Compile/crypto_des.test-10        418.8m ± 0%     408.1m ± 0%    -2.56% (p=0.001 n=7)
TinyGo/Run/crypto_des.test-10            18.23m ± 0%     18.17m ± 1%         ~ (p=0.456 n=7)
TinyGo/Compile/crypto_md5.test-10        417.3m ± 2%     406.1m ± 1%    -2.68% (p=0.001 n=7)
TinyGo/Run/crypto_md5.test-10            20.50m ± 0%     20.45m ± 1%         ~ (p=0.128 n=7)
TinyGo/Compile/crypto_rc4.test-10        402.2m ± 1%     390.5m ± 0%    -2.90% (p=0.001 n=7)
TinyGo/Run/crypto_rc4.test-10            160.8m ± 0%     161.0m ± 1%         ~ (p=1.000 n=7)
TinyGo/Compile/crypto_sha1.test-10       417.2m ± 1%     404.5m ± 1%    -3.04% (p=0.001 n=7)
TinyGo/Run/crypto_sha1.test-10           15.93m ± 1%     15.90m ± 1%         ~ (p=0.710 n=7)
TinyGo/Compile/crypto_sha256.test-10     423.4m ± 1%     412.4m ± 1%    -2.60% (p=0.001 n=7)
TinyGo/Run/crypto_sha256.test-10         16.16m ±  ∞ ¹   16.05m ±  ∞ ¹       ~ (p=0.381 n=2+5)
geomean                                  94.17m          92.70m         -1.56%
¹ need >= 6 samples for confidence interval at level 0.95

                                      │ old_tinygo.txt │             new_tinygo.txt             │
                                      │      B/op      │      B/op       vs base                │
TinyGo/Compile/container_heap.test-10   48.55Mi ± 0%     48.30Mi ± 0%    -0.52% (p=0.001 n=7)
TinyGo/Run/container_heap.test-10       16.63Mi ± 0%     16.63Mi ± 0%         ~ (p=0.557 n=7)
TinyGo/Compile/container_list.test-10   48.53Mi ± 0%     48.29Mi ± 0%    -0.51% (p=0.001 n=7)
TinyGo/Run/container_list.test-10       16.40Mi ± 0%     16.40Mi ± 0%         ~ (p=0.364 n=7)
TinyGo/Compile/container_ring.test-10   47.78Mi ± 0%     47.53Mi ± 0%    -0.52% (p=0.001 n=7)
TinyGo/Run/container_ring.test-10       16.30Mi ± 0%     16.30Mi ± 0%         ~ (p=0.128 n=7)
TinyGo/Compile/crypto_des.test-10       48.67Mi ± 0%     48.42Mi ± 0%    -0.51% (p=0.001 n=7)
TinyGo/Run/crypto_des.test-10           16.76Mi ± 0%     16.76Mi ± 0%         ~ (p=0.902 n=7)
TinyGo/Compile/crypto_md5.test-10       48.73Mi ± 0%     48.48Mi ± 0%    -0.51% (p=0.001 n=7)
TinyGo/Run/crypto_md5.test-10           44.97Mi ± 0%     44.97Mi ± 0%         ~ (p=0.402 n=7)
TinyGo/Compile/crypto_rc4.test-10       47.76Mi ± 0%     47.52Mi ± 0%    -0.51% (p=0.001 n=7)
TinyGo/Run/crypto_rc4.test-10           29.28Mi ± 0%     29.28Mi ± 0%         ~ (p=0.104 n=7)
TinyGo/Compile/crypto_sha1.test-10      48.97Mi ± 0%     48.72Mi ± 0%    -0.52% (p=0.001 n=7)
TinyGo/Run/crypto_sha1.test-10          17.44Mi ± 0%     17.44Mi ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/crypto_sha256.test-10    48.81Mi ± 0%     48.56Mi ± 0%    -0.51% (p=0.001 n=7)
TinyGo/Run/crypto_sha256.test-10        17.53Mi ±  ∞ ¹   17.53Mi ±  ∞ ¹       ~ (p=0.381 n=2+5)
geomean                                 31.45Mi          31.37Mi         -0.26%
¹ need >= 6 samples for confidence interval at level 0.95

                                      │ old_tinygo.txt │            new_tinygo.txt             │
                                      │   allocs/op    │   allocs/op    vs base                │
TinyGo/Compile/container_heap.test-10    83.67k ± 0%     83.46k ± 0%    -0.25% (p=0.011 n=7)
TinyGo/Run/container_heap.test-10        374.9k ± 0%     374.9k ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/container_list.test-10    83.34k ± 0%     83.19k ± 0%    -0.19% (p=0.002 n=7)
TinyGo/Run/container_list.test-10        370.0k ± 0%     370.0k ± 0%         ~ (p=0.674 n=7)
TinyGo/Compile/container_ring.test-10    83.26k ± 0%     83.08k ± 0%    -0.22% (p=0.004 n=7)
TinyGo/Run/container_ring.test-10        367.6k ± 0%     367.6k ± 0%         ~ (p=0.249 n=7)
TinyGo/Compile/crypto_des.test-10        83.68k ± 0%     83.53k ± 0%    -0.18% (p=0.004 n=7)
TinyGo/Run/crypto_des.test-10            378.1k ± 0%     378.1k ± 0%         ~ (p=0.437 n=7)
TinyGo/Compile/crypto_md5.test-10        83.86k ± 0%     83.67k ± 0%    -0.23% (p=0.001 n=7)
TinyGo/Run/crypto_md5.test-10            393.3k ± 0%     393.3k ± 0%         ~ (p=0.592 n=7)
TinyGo/Compile/crypto_rc4.test-10        83.32k ± 0%     83.20k ± 0%    -0.14% (p=0.011 n=7)
TinyGo/Run/crypto_rc4.test-10            367.1k ± 0%     367.1k ± 0%         ~ (p=0.102 n=7)
TinyGo/Compile/crypto_sha1.test-10       84.05k ± 0%     83.87k ± 0%    -0.21% (p=0.002 n=7)
TinyGo/Run/crypto_sha1.test-10           392.7k ± 0%     392.7k ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/crypto_sha256.test-10     83.86k ± 0%     83.67k ± 0%    -0.24% (p=0.001 n=7)
TinyGo/Run/crypto_sha256.test-10         394.5k ±  ∞ ¹   394.5k ±  ∞ ¹       ~ (p=0.952 n=2+5)
geomean                                  178.2k          178.0k         -0.10%
```

### wasip1

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/stdlibs
                                            │ old_wasip1.txt │           new_wasip1.txt            │
                                            │     sec/op     │   sec/op     vs base                │
Wasip1/Compile/src_archive_tar.test-10          2.066 ± 1%      2.066 ± 1%       ~ (p=1.000 n=7)
Wasip1/Run/src_archive_tar.test-10             398.9m ± 1%     398.9m ± 0%       ~ (p=0.902 n=7)
Wasip1/Compile/src_bufio.test-10                1.405 ± 0%      1.405 ± 0%       ~ (p=0.318 n=7)
Wasip1/Run/src_bufio.test-10                   120.1m ± 0%     120.0m ± 0%       ~ (p=0.456 n=7)
Wasip1/Compile/src_bytes.test-10                1.453 ± 0%      1.452 ± 0%       ~ (p=0.383 n=7)
Wasip1/Run/src_bytes.test-10                   468.9m ± 1%     467.7m ± 1%       ~ (p=1.000 n=7)
Wasip1/Compile/src_context.test-10              1.565 ± 0%      1.562 ± 0%  -0.18% (p=0.001 n=7)
Wasip1/Run/src_context.test-10                 31.52m ± 1%     31.51m ± 1%       ~ (p=0.620 n=7)
Wasip1/Compile/src_encoding_ascii85.test-10     1.262 ±  ∞ ¹    1.262 ± 0%       ~ (p=0.889 n=2+7)
geomean                                        565.3m          564.9m       -0.07%
¹ need >= 6 samples for confidence interval at level 0.95

                                            │ old_wasip1.txt │            new_wasip1.txt            │
                                            │      B/op      │     B/op      vs base                │
Wasip1/Compile/src_archive_tar.test-10        93.16Mi ± 0%     92.70Mi ± 0%  -0.50% (p=0.001 n=7)
Wasip1/Run/src_archive_tar.test-10            286.0Mi ± 0%     286.0Mi ± 0%       ~ (p=0.246 n=7)
Wasip1/Compile/src_bufio.test-10              74.12Mi ± 0%     73.79Mi ± 0%  -0.45% (p=0.001 n=7)
Wasip1/Run/src_bufio.test-10                  105.3Mi ± 0%     105.3Mi ± 0%       ~ (p=0.780 n=7)
Wasip1/Compile/src_bytes.test-10              75.32Mi ± 0%     74.96Mi ± 0%  -0.47% (p=0.001 n=7)
Wasip1/Run/src_bytes.test-10                  605.0Mi ± 0%     605.0Mi ± 0%       ~ (p=1.000 n=7)
Wasip1/Compile/src_context.test-10            78.07Mi ± 0%     77.68Mi ± 0%  -0.49% (p=0.001 n=7)
Wasip1/Run/src_context.test-10                71.52Mi ± 0%     71.52Mi ± 0%       ~ (p=0.516 n=7)
Wasip1/Compile/src_encoding_ascii85.test-10   70.38Mi ±  ∞ ¹   70.08Mi ± 0%       ~ (p=0.056 n=2+7)
geomean                                       115.7Mi          115.4Mi       -0.26%
¹ need >= 6 samples for confidence interval at level 0.95

                                            │ old_wasip1.txt │            new_wasip1.txt             │
                                            │   allocs/op    │  allocs/op   vs base                  │
Wasip1/Compile/src_archive_tar.test-10         265.0k ± 0%     256.1k ± 0%  -3.37% (p=0.001 n=7)
Wasip1/Run/src_archive_tar.test-10             7.831k ± 0%     7.830k ± 0%       ~ (p=0.592 n=7)
Wasip1/Compile/src_bufio.test-10               195.3k ± 0%     189.1k ± 0%  -3.19% (p=0.001 n=7)
Wasip1/Run/src_bufio.test-10                   3.728k ± 0%     3.728k ± 0%       ~ (p=1.000 n=7)   ¹
Wasip1/Compile/src_bytes.test-10               203.7k ± 0%     197.0k ± 0%  -3.31% (p=0.001 n=7)
Wasip1/Run/src_bytes.test-10                   6.377k ± 0%     6.377k ± 0%       ~ (p=0.559 n=7)
Wasip1/Compile/src_context.test-10             221.4k ± 0%     214.2k ± 0%  -3.29% (p=0.001 n=7)
Wasip1/Run/src_context.test-10                 3.814k ± 1%     3.814k ± 0%       ~ (p=0.192 n=7)
Wasip1/Compile/src_encoding_ascii85.test-10    182.3k ±  ∞ ²   176.6k ± 0%       ~ (p=0.056 n=2+7)
geomean                                        40.64k          39.90k       -1.82%
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-07 12:50:25 -07:00
Takeshi Yoneda
747609b0f5 ssa: removes map use for block traversals (#2235)
This removes the use of map in basic block traversals.
As a result, overall compilation perf improves like the below:

### Zig
```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/stdlibs
                             │ old_zig.txt │            new_zig.txt            │
                             │   sec/op    │   sec/op    vs base               │
Zig/Compile/test-opt.wasm-10    4.438 ± 1%   3.778 ± 0%  -14.87% (p=0.002 n=6)
Zig/Run/test-opt.wasm-10        18.77 ± 1%   18.76 ± 0%        ~ (p=0.818 n=6)
Zig/Compile/test.wasm-10        5.083 ± 0%   4.673 ± 0%   -8.07% (p=0.002 n=6)
Zig/Run/test.wasm-10            19.27 ± 1%   19.30 ± 1%        ~ (p=0.699 n=6)
geomean                         9.504        8.941        -5.92%

                             │ old_zig.txt  │            new_zig.txt             │
                             │     B/op     │     B/op      vs base              │
Zig/Compile/test-opt.wasm-10   396.7Mi ± 0%   394.7Mi ± 0%  -0.51% (p=0.002 n=6)
Zig/Run/test-opt.wasm-10       741.7Mi ± 0%   741.7Mi ± 0%       ~ (p=0.900 n=6)
Zig/Compile/test.wasm-10       660.0Mi ± 0%   659.5Mi ± 0%  -0.08% (p=0.002 n=6)
Zig/Run/test.wasm-10           1.296Gi ± 0%   1.296Gi ± 0%       ~ (p=0.892 n=6)
geomean                        712.6Mi        711.5Mi       -0.15%

                             │ old_zig.txt │            new_zig.txt            │
                             │  allocs/op  │  allocs/op   vs base              │
Zig/Compile/test-opt.wasm-10   363.2k ± 0%   362.6k ± 0%  -0.17% (p=0.002 n=6)
Zig/Run/test-opt.wasm-10       51.58k ± 0%   51.58k ± 0%       ~ (p=0.933 n=6)
Zig/Compile/test.wasm-10       515.2k ± 0%   515.4k ± 0%       ~ (p=0.485 n=6)
Zig/Run/test.wasm-10           2.156M ± 0%   2.156M ± 0%       ~ (p=0.998 n=6)
geomean                        379.8k        379.7k       -0.03%
```

### wasip1

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/stdlibs
                                            │ old_wasip1.txt │            new_wasip1.txt             │
                                            │     sec/op     │    sec/op      vs base                │
Wasip1/Compile/src_archive_tar.test-10            2.198 ± 1%    2.067 ± 1%    -5.96% (p=0.001 n=7)
Wasip1/Run/src_archive_tar.test-10               398.8m ± 0%   398.8m ± 0%         ~ (p=0.902 n=7)
Wasip1/Compile/src_bufio.test-10                  1.492 ± 0%    1.409 ± 1%    -5.57% (p=0.001 n=7)
Wasip1/Run/src_bufio.test-10                     120.5m ± 1%   121.0m ± 1%    +0.44% (p=0.017 n=7)
Wasip1/Compile/src_bytes.test-10                  1.543 ± 0%    1.454 ± 0%    -5.72% (p=0.001 n=7)
Wasip1/Run/src_bytes.test-10                     469.0m ± 1%   467.4m ± 1%         ~ (p=0.209 n=7)
Wasip1/Compile/src_context.test-10                1.664 ± 0%    1.564 ± 1%    -6.00% (p=0.001 n=7)
Wasip1/Run/src_context.test-10                   31.54m ± 1%   31.57m ± 0%         ~ (p=0.445 n=6+7)
Wasip1/Compile/src_encoding_ascii85.test-10                     1.261 ±  ∞ ¹
geomean                                          527.3m        565.9m         -2.92%
¹ need >= 6 samples for confidence interval at level 0.95

                                            │ old_wasip1.txt │             new_wasip1.txt             │
                                            │      B/op      │      B/op       vs base                │
Wasip1/Compile/src_archive_tar.test-10          93.44Mi ± 0%   93.17Mi ± 0%    -0.30% (p=0.001 n=7)
Wasip1/Run/src_archive_tar.test-10              286.0Mi ± 0%   286.0Mi ± 0%         ~ (p=0.593 n=7)
Wasip1/Compile/src_bufio.test-10                74.38Mi ± 0%   74.13Mi ± 0%    -0.35% (p=0.001 n=7)
Wasip1/Run/src_bufio.test-10                    105.3Mi ± 0%   105.3Mi ± 0%         ~ (p=0.780 n=7)
Wasip1/Compile/src_bytes.test-10                75.58Mi ± 0%   75.32Mi ± 0%    -0.35% (p=0.001 n=7)
Wasip1/Run/src_bytes.test-10                    605.0Mi ± 0%   605.0Mi ± 0%         ~ (p=0.331 n=7)
Wasip1/Compile/src_context.test-10              78.33Mi ± 0%   78.07Mi ± 0%    -0.33% (p=0.001 n=7)
Wasip1/Run/src_context.test-10                  71.52Mi ± 0%   71.52Mi ± 0%         ~ (p=1.000 n=6+7)
Wasip1/Compile/src_encoding_ascii85.test-10                    70.38Mi ±  ∞ ¹
geomean                                         123.4Mi        115.7Mi         -0.17%
¹ need >= 6 samples for confidence interval at level 0.95

                                            │ old_wasip1.txt │             new_wasip1.txt              │
                                            │   allocs/op    │   allocs/op    vs base                  │
Wasip1/Compile/src_archive_tar.test-10           265.4k ± 0%   265.0k ± 0%    -0.16% (p=0.001 n=7)
Wasip1/Run/src_archive_tar.test-10               7.831k ± 0%   7.830k ± 0%         ~ (p=1.000 n=7)
Wasip1/Compile/src_bufio.test-10                 195.6k ± 0%   195.4k ± 0%    -0.12% (p=0.001 n=7)
Wasip1/Run/src_bufio.test-10                     3.728k ± 0%   3.728k ± 0%         ~ (p=1.000 n=7)   ¹
Wasip1/Compile/src_bytes.test-10                 204.1k ± 0%   203.7k ± 0%    -0.20% (p=0.001 n=7)
Wasip1/Run/src_bytes.test-10                     6.377k ± 0%   6.377k ± 0%         ~ (p=1.000 n=7)
Wasip1/Compile/src_context.test-10               221.7k ± 0%   221.6k ± 0%    -0.06% (p=0.001 n=7)
Wasip1/Run/src_context.test-10                   3.814k ± 0%   3.814k ± 1%         ~ (p=0.140 n=6+7)
Wasip1/Compile/src_encoding_ascii85.test-10                    182.3k ±  ∞ ²
geomean                                          33.71k        40.64k         -0.07%
¹ all samples are equal
² need >= 6 samples for confidence interval at level 0.95
```


### TinyGo
```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/stdlibs
                                      │ old_tinygo.txt │            new_tinygo.txt             │
                                      │     sec/op     │    sec/op      vs base                │
TinyGo/Compile/container_heap.test-10    410.8m ± 1%     399.8m ± 0%    -2.69% (p=0.001 n=7)
TinyGo/Run/container_heap.test-10        14.41m ± 0%     14.29m ± 2%    -0.77% (p=0.026 n=7)
TinyGo/Compile/container_list.test-10    410.5m ± 1%     398.1m ± 0%    -3.02% (p=0.001 n=7)
TinyGo/Run/container_list.test-10        14.27m ± 2%     14.16m ± 1%         ~ (p=0.073 n=7)
TinyGo/Compile/container_ring.test-10    403.7m ± 1%     392.5m ± 2%    -2.77% (p=0.001 n=7)
TinyGo/Run/container_ring.test-10        14.24m ± 0%     14.27m ± 1%         ~ (p=0.259 n=7)
TinyGo/Compile/crypto_des.test-10        418.8m ± 0%     408.1m ± 0%    -2.56% (p=0.001 n=7)
TinyGo/Run/crypto_des.test-10            18.23m ± 0%     18.17m ± 1%         ~ (p=0.456 n=7)
TinyGo/Compile/crypto_md5.test-10        417.3m ± 2%     406.1m ± 1%    -2.68% (p=0.001 n=7)
TinyGo/Run/crypto_md5.test-10            20.50m ± 0%     20.45m ± 1%         ~ (p=0.128 n=7)
TinyGo/Compile/crypto_rc4.test-10        402.2m ± 1%     390.5m ± 0%    -2.90% (p=0.001 n=7)
TinyGo/Run/crypto_rc4.test-10            160.8m ± 0%     161.0m ± 1%         ~ (p=1.000 n=7)
TinyGo/Compile/crypto_sha1.test-10       417.2m ± 1%     404.5m ± 1%    -3.04% (p=0.001 n=7)
TinyGo/Run/crypto_sha1.test-10           15.93m ± 1%     15.90m ± 1%         ~ (p=0.710 n=7)
TinyGo/Compile/crypto_sha256.test-10     423.4m ± 1%     412.4m ± 1%    -2.60% (p=0.001 n=7)
TinyGo/Run/crypto_sha256.test-10         16.16m ±  ∞ ¹   16.05m ±  ∞ ¹       ~ (p=0.381 n=2+5)
geomean                                  94.17m          92.70m         -1.56%
¹ need >= 6 samples for confidence interval at level 0.95

                                      │ old_tinygo.txt │             new_tinygo.txt             │
                                      │      B/op      │      B/op       vs base                │
TinyGo/Compile/container_heap.test-10   48.55Mi ± 0%     48.30Mi ± 0%    -0.52% (p=0.001 n=7)
TinyGo/Run/container_heap.test-10       16.63Mi ± 0%     16.63Mi ± 0%         ~ (p=0.557 n=7)
TinyGo/Compile/container_list.test-10   48.53Mi ± 0%     48.29Mi ± 0%    -0.51% (p=0.001 n=7)
TinyGo/Run/container_list.test-10       16.40Mi ± 0%     16.40Mi ± 0%         ~ (p=0.364 n=7)
TinyGo/Compile/container_ring.test-10   47.78Mi ± 0%     47.53Mi ± 0%    -0.52% (p=0.001 n=7)
TinyGo/Run/container_ring.test-10       16.30Mi ± 0%     16.30Mi ± 0%         ~ (p=0.128 n=7)
TinyGo/Compile/crypto_des.test-10       48.67Mi ± 0%     48.42Mi ± 0%    -0.51% (p=0.001 n=7)
TinyGo/Run/crypto_des.test-10           16.76Mi ± 0%     16.76Mi ± 0%         ~ (p=0.902 n=7)
TinyGo/Compile/crypto_md5.test-10       48.73Mi ± 0%     48.48Mi ± 0%    -0.51% (p=0.001 n=7)
TinyGo/Run/crypto_md5.test-10           44.97Mi ± 0%     44.97Mi ± 0%         ~ (p=0.402 n=7)
TinyGo/Compile/crypto_rc4.test-10       47.76Mi ± 0%     47.52Mi ± 0%    -0.51% (p=0.001 n=7)
TinyGo/Run/crypto_rc4.test-10           29.28Mi ± 0%     29.28Mi ± 0%         ~ (p=0.104 n=7)
TinyGo/Compile/crypto_sha1.test-10      48.97Mi ± 0%     48.72Mi ± 0%    -0.52% (p=0.001 n=7)
TinyGo/Run/crypto_sha1.test-10          17.44Mi ± 0%     17.44Mi ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/crypto_sha256.test-10    48.81Mi ± 0%     48.56Mi ± 0%    -0.51% (p=0.001 n=7)
TinyGo/Run/crypto_sha256.test-10        17.53Mi ±  ∞ ¹   17.53Mi ±  ∞ ¹       ~ (p=0.381 n=2+5)
geomean                                 31.45Mi          31.37Mi         -0.26%
¹ need >= 6 samples for confidence interval at level 0.95

                                      │ old_tinygo.txt │            new_tinygo.txt             │
                                      │   allocs/op    │   allocs/op    vs base                │
TinyGo/Compile/container_heap.test-10    83.67k ± 0%     83.46k ± 0%    -0.25% (p=0.011 n=7)
TinyGo/Run/container_heap.test-10        374.9k ± 0%     374.9k ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/container_list.test-10    83.34k ± 0%     83.19k ± 0%    -0.19% (p=0.002 n=7)
TinyGo/Run/container_list.test-10        370.0k ± 0%     370.0k ± 0%         ~ (p=0.674 n=7)
TinyGo/Compile/container_ring.test-10    83.26k ± 0%     83.08k ± 0%    -0.22% (p=0.004 n=7)
TinyGo/Run/container_ring.test-10        367.6k ± 0%     367.6k ± 0%         ~ (p=0.249 n=7)
TinyGo/Compile/crypto_des.test-10        83.68k ± 0%     83.53k ± 0%    -0.18% (p=0.004 n=7)
TinyGo/Run/crypto_des.test-10            378.1k ± 0%     378.1k ± 0%         ~ (p=0.437 n=7)
TinyGo/Compile/crypto_md5.test-10        83.86k ± 0%     83.67k ± 0%    -0.23% (p=0.001 n=7)
TinyGo/Run/crypto_md5.test-10            393.3k ± 0%     393.3k ± 0%         ~ (p=0.592 n=7)
TinyGo/Compile/crypto_rc4.test-10        83.32k ± 0%     83.20k ± 0%    -0.14% (p=0.011 n=7)
TinyGo/Run/crypto_rc4.test-10            367.1k ± 0%     367.1k ± 0%         ~ (p=0.102 n=7)
TinyGo/Compile/crypto_sha1.test-10       84.05k ± 0%     83.87k ± 0%    -0.21% (p=0.002 n=7)
TinyGo/Run/crypto_sha1.test-10           392.7k ± 0%     392.7k ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/crypto_sha256.test-10     83.86k ± 0%     83.67k ± 0%    -0.24% (p=0.001 n=7)
TinyGo/Run/crypto_sha256.test-10         394.5k ±  ∞ ¹   394.5k ±  ∞ ¹       ~ (p=0.952 n=2+5)
geomean                                  178.2k          178.0k         -0.10%
```

### wazero compiled as wasip1 binary

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
               │  old.txt   │             new.txt              │
               │   sec/op   │   sec/op    vs base              │
Compilation-10   2.413 ± 0%   2.258 ± 1%  -6.42% (p=0.001 n=7)

               │   old.txt    │              new.txt               │
               │     B/op     │     B/op      vs base              │
Compilation-10   339.9Mi ± 0%   337.7Mi ± 0%  -0.63% (p=0.001 n=7)

               │   old.txt   │              new.txt              │
               │  allocs/op  │  allocs/op   vs base              │
Compilation-10   603.9k ± 0%   602.4k ± 0%  -0.25% (p=0.001 n=7)
```


Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-07 11:42:45 -07:00
Takeshi Yoneda
f47fd2e46e ssa: memory usage optimization around lastDefinitions (#2233)
This avoids the unnecessary duplicated zero initial value definitions 
for Wasm function locals. As a result, for certain binaries which
have huge number of locals like Zig standard libraries,  we can see
1~10% improvements in compilation performance without impacting 
other cases like the below.

### Zig Stdlib tests
```
                             │ old_zig.txt │            new_zig.txt            │
                             │   sec/op    │   sec/op    vs base               │
Zig/Compile/test-opt.wasm-10    4.466 ± 2%   4.399 ± 0%   -1.50% (p=0.007 n=7)
Zig/Run/test-opt.wasm-10        18.86 ± 0%   18.84 ± 0%        ~ (p=0.535 n=7)
Zig/Compile/test.wasm-10        5.684 ± 1%   5.084 ± 1%  -10.55% (p=0.001 n=7)
Zig/Run/test.wasm-10            19.28 ± 1%   19.25 ± 1%        ~ (p=0.535 n=7)
geomean                         9.802        9.490        -3.18%

                             │ old_zig.txt  │            new_zig.txt             │
                             │     B/op     │     B/op      vs base              │
Zig/Compile/test-opt.wasm-10   395.4Mi ± 0%   396.7Mi ± 0%  +0.32% (p=0.001 n=7)
Zig/Run/test-opt.wasm-10       741.7Mi ± 0%   741.7Mi ± 0%       ~ (p=0.941 n=7)
Zig/Compile/test.wasm-10       671.6Mi ± 0%   660.1Mi ± 0%  -1.72% (p=0.001 n=7)
Zig/Run/test.wasm-10           1.296Gi ± 0%   1.296Gi ± 0%       ~ (p=0.363 n=7)
geomean                        715.1Mi        712.6Mi       -0.35%

                             │ old_zig.txt │            new_zig.txt            │
                             │  allocs/op  │  allocs/op   vs base              │
Zig/Compile/test-opt.wasm-10   363.1k ± 0%   363.2k ± 0%       ~ (p=0.456 n=7)
Zig/Run/test-opt.wasm-10       51.58k ± 0%   51.58k ± 0%       ~ (p=0.812 n=7)
Zig/Compile/test.wasm-10       516.3k ± 0%   515.5k ± 0%  -0.16% (p=0.001 n=7)
Zig/Run/test.wasm-10           2.156M ± 0%   2.156M ± 0%       ~ (p=0.171 n=7)
geomean                        380.0k        379.8k       -0.03%
```

### wazero compiled as wasip1 binary 
```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
               │  old.txt   │           new.txt           │
               │   sec/op   │   sec/op    vs base         │
Compilation-10   2.418 ± 0%   2.421 ± 0%  ~ (p=0.383 n=7)

               │   old.txt    │              new.txt               │
               │     B/op     │     B/op      vs base              │
Compilation-10   339.9Mi ± 0%   339.9Mi ± 0%  -0.01% (p=0.001 n=7)

               │   old.txt   │           new.txt            │
               │  allocs/op  │  allocs/op   vs base         │
Compilation-10   603.9k ± 0%   604.0k ± 0%  ~ (p=0.620 n=7)
```

### TinyGo 
```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/stdlibs
                                      │ old_tinygo.txt │            new_tinygo.txt             │
                                      │     sec/op     │    sec/op      vs base                │
TinyGo/Compile/container_heap.test-10    414.1m ± 0%     413.1m ± 1%         ~ (p=0.165 n=7)
TinyGo/Run/container_heap.test-10        14.48m ± 1%     14.54m ± 1%         ~ (p=0.383 n=7)
TinyGo/Compile/container_list.test-10    413.1m ± 1%     412.1m ± 1%         ~ (p=0.620 n=7)
TinyGo/Run/container_list.test-10        14.29m ± 0%     14.33m ± 1%         ~ (p=0.259 n=7)
TinyGo/Compile/container_ring.test-10    406.8m ± 1%     407.1m ± 1%         ~ (p=0.902 n=7)
TinyGo/Run/container_ring.test-10        14.28m ± 1%     14.29m ± 1%         ~ (p=0.318 n=7)
TinyGo/Compile/crypto_des.test-10        421.3m ± 0%     422.4m ± 1%         ~ (p=0.209 n=7)
TinyGo/Run/crypto_des.test-10            18.32m ± 1%     18.38m ± 2%         ~ (p=0.209 n=7)
TinyGo/Compile/crypto_md5.test-10        418.7m ± 1%     419.8m ± 0%         ~ (p=0.318 n=7)
TinyGo/Run/crypto_md5.test-10            21.78m ± 5%     20.65m ± 2%         ~ (p=0.165 n=7)
TinyGo/Compile/crypto_rc4.test-10        421.8m ± 4%     404.3m ± 1%    -4.16% (p=0.001 n=7)
TinyGo/Run/crypto_rc4.test-10            162.6m ± 1%     162.3m ± 1%         ~ (p=0.318 n=7)
TinyGo/Compile/crypto_sha1.test-10       420.5m ± 1%     419.4m ± 1%         ~ (p=0.535 n=7)
TinyGo/Run/crypto_sha1.test-10           16.04m ± 1%     16.12m ± 1%    +0.50% (p=0.038 n=7)
TinyGo/Compile/crypto_sha256.test-10     426.8m ± 0%     427.4m ± 1%         ~ (p=1.000 n=7)
TinyGo/Run/crypto_sha256.test-10         16.24m ±  ∞ ¹   16.38m ±  ∞ ¹       ~ (p=1.000 n=1) ²
geomean                                  95.31m          94.88m         -0.45%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

                                      │ old_tinygo.txt │             new_tinygo.txt             │
                                      │      B/op      │      B/op       vs base                │
TinyGo/Compile/container_heap.test-10   48.58Mi ± 0%     48.55Mi ± 0%    -0.06% (p=0.001 n=7)
TinyGo/Run/container_heap.test-10       16.63Mi ± 0%     16.63Mi ± 0%         ~ (p=0.620 n=7)
TinyGo/Compile/container_list.test-10   48.56Mi ± 0%     48.54Mi ± 0%    -0.05% (p=0.001 n=7)
TinyGo/Run/container_list.test-10       16.40Mi ± 0%     16.40Mi ± 0%         ~ (p=0.535 n=7)
TinyGo/Compile/container_ring.test-10   47.81Mi ± 0%     47.78Mi ± 0%    -0.05% (p=0.001 n=7)
TinyGo/Run/container_ring.test-10       16.30Mi ± 0%     16.30Mi ± 0%         ~ (p=0.871 n=7)
TinyGo/Compile/crypto_des.test-10       48.70Mi ± 0%     48.67Mi ± 0%    -0.05% (p=0.001 n=7)
TinyGo/Run/crypto_des.test-10           16.76Mi ± 0%     16.76Mi ± 0%         ~ (p=0.119 n=7)
TinyGo/Compile/crypto_md5.test-10       48.75Mi ± 0%     48.73Mi ± 0%    -0.03% (p=0.001 n=7)
TinyGo/Run/crypto_md5.test-10           44.97Mi ± 0%     44.97Mi ± 0%         ~ (p=0.333 n=7)
TinyGo/Compile/crypto_rc4.test-10       47.79Mi ± 0%     47.76Mi ± 0%    -0.06% (p=0.001 n=7)
TinyGo/Run/crypto_rc4.test-10           29.28Mi ± 0%     29.28Mi ± 0%         ~ (p=0.274 n=7)
TinyGo/Compile/crypto_sha1.test-10      48.99Mi ± 0%     48.97Mi ± 0%    -0.03% (p=0.001 n=7)
TinyGo/Run/crypto_sha1.test-10          17.44Mi ± 0%     17.44Mi ± 0%         ~ (p=0.456 n=7)
TinyGo/Compile/crypto_sha256.test-10    48.82Mi ± 0%     48.81Mi ± 0%    -0.03% (p=0.004 n=7)
TinyGo/Run/crypto_sha256.test-10        17.53Mi ±  ∞ ¹   17.53Mi ±  ∞ ¹       ~ (p=1.000 n=1) ²
geomean                                 31.45Mi          31.45Mi         -0.02%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

                                      │ old_tinygo.txt │            new_tinygo.txt             │
                                      │   allocs/op    │   allocs/op    vs base                │
TinyGo/Compile/container_heap.test-10    83.64k ± 0%     83.63k ± 0%         ~ (p=0.365 n=7)
TinyGo/Run/container_heap.test-10        374.9k ± 0%     374.9k ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/container_list.test-10    83.38k ± 0%     83.39k ± 0%         ~ (p=0.805 n=7)
TinyGo/Run/container_list.test-10        370.0k ± 0%     370.0k ± 0%         ~ (p=0.633 n=7)
TinyGo/Compile/container_ring.test-10    83.30k ± 0%     83.35k ± 0%         ~ (p=1.000 n=7)
TinyGo/Run/container_ring.test-10        367.6k ± 0%     367.6k ± 0%         ~ (p=0.617 n=7)
TinyGo/Compile/crypto_des.test-10        83.67k ± 0%     83.70k ± 0%         ~ (p=0.805 n=7)
TinyGo/Run/crypto_des.test-10            378.1k ± 0%     378.1k ± 0%         ~ (p=0.078 n=7)
TinyGo/Compile/crypto_md5.test-10        83.81k ± 0%     83.84k ± 0%         ~ (p=0.805 n=7)
TinyGo/Run/crypto_md5.test-10            393.3k ± 0%     393.3k ± 0%         ~ (p=0.690 n=7)
TinyGo/Compile/crypto_rc4.test-10        83.39k ± 0%     83.33k ± 0%         ~ (p=0.097 n=7)
TinyGo/Run/crypto_rc4.test-10            367.1k ± 0%     367.1k ± 0%         ~ (p=0.232 n=7)
TinyGo/Compile/crypto_sha1.test-10       84.00k ± 0%     84.06k ± 0%         ~ (p=0.154 n=7)
TinyGo/Run/crypto_sha1.test-10           392.7k ± 0%     392.7k ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/crypto_sha256.test-10     83.85k ± 0%     83.86k ± 0%         ~ (p=0.620 n=7)
TinyGo/Run/crypto_sha256.test-10         394.5k ±  ∞ ¹   394.5k ±  ∞ ¹       ~ (p=1.000 n=1) ²
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-07 07:57:15 -07:00
Yage Hu
0c5d97141e Fix path_symlink only works when dir mounted to / (#2229) 2024-06-05 19:51:59 -07:00
Takeshi Yoneda
506c922f0b ssa: reuses slice on basicBlock.loopNestingForestChildren (#2232)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-05 14:33:58 -07:00
Takeshi Yoneda
8dd9d5a946 ssa: removes the deadcode on BasicBlock (#2231)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-05 14:15:06 -07:00
Takeshi Yoneda
244281beb8 backend: removes the map use in ExecutableContext[Instr] (#2230)
This makes the compilation slightly more faster with less memory:
```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
               │  old.txt   │             new.txt              │
               │   sec/op   │   sec/op    vs base              │
Compilation-10   2.488 ± 0%   2.438 ± 0%  -2.00% (p=0.001 n=7)

               │   old.txt    │              new.txt               │
               │     B/op     │     B/op      vs base              │
Compilation-10   341.1Mi ± 0%   340.3Mi ± 0%  -0.23% (p=0.001 n=7)

               │   old.txt   │              new.txt              │
               │  allocs/op  │  allocs/op   vs base              │
Compilation-10   607.0k ± 0%   605.5k ± 0%  -0.26% (p=0.001 n=7)
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-05 09:19:37 -07:00
Takeshi Yoneda
38a9374cb1 regalloc: simplifies regInUseSet (#2227)
This makes the compilation slightly faster and simplifies the codebase.

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
               │  old.txt   │             new.txt              │
               │   sec/op   │   sec/op    vs base              │
Compilation-10   2.499 ± 0%   2.478 ± 2%  -0.84% (p=0.026 n=7)

               │   old.txt    │            new.txt            │
               │     B/op     │     B/op      vs base         │
Compilation-10   341.0Mi ± 0%   341.1Mi ± 0%  ~ (p=0.128 n=7)

               │   old.txt   │           new.txt            │
               │  allocs/op  │  allocs/op   vs base         │
Compilation-10   606.9k ± 0%   606.9k ± 0%  ~ (p=0.383 n=7)
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-04 08:27:03 -07:00
Takeshi Yoneda
1fdaa0c737 regalloc: removes the last use of map for faster allocation (#2226)
This refactors `fixMergeState` function to remove the last use of map,
which previously caused a lot of allocations.

As a result, this improves the compilation time ~2% and makes it to use
less memory allocations. The blow is the benchmark results for the 
standard libraries as well as compiling wazero itself.

### Zig

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/stdlibs
                             │ old_zig.txt │           new_zig.txt            │
                             │   sec/op    │   sec/op    vs base              │
Zig/Compile/test-opt.wasm-10    4.503 ± 1%   4.497 ± 1%       ~ (p=0.902 n=7)
Zig/Run/test-opt.wasm-10        19.09 ± 1%   18.79 ± 1%  -1.56% (p=0.001 n=7)
Zig/Compile/test.wasm-10        5.739 ± 2%   5.712 ± 0%  -0.47% (p=0.002 n=7)
Zig/Run/test.wasm-10            19.36 ± 1%   19.17 ± 1%       ~ (p=0.097 n=7)
geomean                         9.886        9.808       -0.79%

                             │ old_zig.txt  │            new_zig.txt             │
                             │     B/op     │     B/op      vs base              │
Zig/Compile/test-opt.wasm-10   400.3Mi ± 0%   398.0Mi ± 0%  -0.58% (p=0.001 n=7)
Zig/Run/test-opt.wasm-10       741.7Mi ± 0%   741.7Mi ± 0%       ~ (p=0.932 n=7)
Zig/Compile/test.wasm-10       672.8Mi ± 0%   672.5Mi ± 0%  -0.04% (p=0.001 n=7)
Zig/Run/test.wasm-10           1.296Gi ± 0%   1.296Gi ± 0%       ~ (p=0.958 n=7)
geomean                        717.6Mi        716.5Mi       -0.16%

                             │ old_zig.txt │            new_zig.txt            │
                             │  allocs/op  │  allocs/op   vs base              │
Zig/Compile/test-opt.wasm-10   387.1k ± 0%   370.3k ± 0%  -4.35% (p=0.001 n=7)
Zig/Run/test-opt.wasm-10       51.58k ± 0%   51.58k ± 0%       ~ (p=0.735 n=7)
Zig/Compile/test.wasm-10       521.2k ± 0%   518.9k ± 0%  -0.43% (p=0.001 n=7)
Zig/Run/test.wasm-10           2.156M ± 0%   2.156M ± 0%       ~ (p=1.000 n=7)
geomean                        387.0k        382.3k       -1.21%
```

### wasip1

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/stdlibs
                                            │ old_wasip1.txt │            new_wasip1.txt             │
                                            │     sec/op     │    sec/op      vs base                │
Wasip1/Compile/src_archive_tar.test-10          2.306 ± 1%      2.257 ± 1%    -2.09% (p=0.001 n=7)
Wasip1/Run/src_archive_tar.test-10             397.8m ± 0%     398.9m ± 1%    +0.28% (p=0.002 n=7)
Wasip1/Compile/src_bufio.test-10                1.565 ± 0%      1.531 ± 3%    -2.16% (p=0.026 n=7)
Wasip1/Run/src_bufio.test-10                   120.7m ± 1%     121.2m ± 0%    +0.40% (p=0.026 n=7)
Wasip1/Compile/src_bytes.test-10                1.622 ± 0%      1.584 ± 0%    -2.32% (p=0.001 n=7)
Wasip1/Run/src_bytes.test-10                   469.2m ± 0%     467.3m ± 1%         ~ (p=0.259 n=7)
Wasip1/Compile/src_context.test-10              1.749 ± 1%      1.709 ± 0%    -2.28% (p=0.001 n=7)
Wasip1/Run/src_context.test-10                 31.54m ± 1%     31.59m ± 1%         ~ (p=0.805 n=7)
Wasip1/Compile/src_encoding_ascii85.test-10     1.409 ± 0%      1.376 ± 0%    -2.35% (p=0.001 n=7)
Wasip1/Run/src_encoding_ascii85.test-10        7.563m ± 1%     7.169m ± 2%    -5.21% (p=0.001 n=7)
Wasip1/Compile/src_encoding_asn1.test-10        1.617 ± 3%      1.585 ± 0%    -1.97% (p=0.001 n=7)
Wasip1/Run/src_encoding_asn1.test-10           8.321m ± 2%     8.196m ± 2%         ~ (p=0.053 n=7)
Wasip1/Compile/src_encoding_base32.test-10      1.459 ± 0%      1.425 ± 0%    -2.28% (p=0.001 n=7)
Wasip1/Run/src_encoding_base32.test-10         28.81m ± 3%     28.11m ± 1%    -2.40% (p=0.038 n=7)
Wasip1/Compile/src_encoding_base64.test-10      1.476 ± 0%      1.439 ± 0%    -2.46% (p=0.001 n=7)
Wasip1/Run/src_encoding_base64.test-10         11.92m ± 3%     11.86m ± 2%         ~ (p=0.209 n=7)
Wasip1/Compile/src_encoding_binary.test-10      1.508 ± 0%      1.476 ± 0%    -2.17% (p=0.001 n=7)
Wasip1/Run/src_encoding_binary.test-10         9.437m ± 3%     9.254m ± 2%    -1.94% (p=0.017 n=7)
Wasip1/Compile/src_encoding_csv.test-10         1.471 ± 0%      1.433 ± 1%    -2.60% (p=0.001 n=7)
Wasip1/Run/src_encoding_csv.test-10            20.05m ± 4%     19.55m ± 1%    -2.50% (p=0.001 n=7)
Wasip1/Compile/src_encoding_gob.test-10         1.991 ± 0%      1.952 ± 0%    -1.97% (p=0.001 n=7)
Wasip1/Run/src_encoding_gob.test-10             9.970 ±  ∞ ¹    9.764 ±  ∞ ¹  -2.07% (p=0.016 n=4+5)
geomean                                        309.9m          304.2m         -1.84%
¹ need >= 6 samples for confidence interval at level 0.95

                                            │ old_wasip1.txt  │             new_wasip1.txt              │
                                            │      B/op       │      B/op       vs base                 │
Wasip1/Compile/src_archive_tar.test-10        104.22Mi ± 0%     93.65Mi ± 0%    -10.14% (p=0.001 n=7)
Wasip1/Run/src_archive_tar.test-10             286.0Mi ± 0%     286.0Mi ± 0%          ~ (p=0.971 n=7)
Wasip1/Compile/src_bufio.test-10               81.91Mi ± 0%     74.57Mi ± 0%     -8.95% (p=0.001 n=7)
Wasip1/Run/src_bufio.test-10                   105.3Mi ± 0%     105.3Mi ± 0%          ~ (p=0.135 n=7)
Wasip1/Compile/src_bytes.test-10               83.42Mi ± 0%     75.77Mi ± 0%     -9.17% (p=0.001 n=7)
Wasip1/Run/src_bytes.test-10                   605.0Mi ± 0%     605.0Mi ± 0%          ~ (p=0.890 n=7)
Wasip1/Compile/src_context.test-10             86.57Mi ± 0%     78.52Mi ± 0%     -9.30% (p=0.001 n=7)
Wasip1/Run/src_context.test-10                 71.52Mi ± 0%     71.52Mi ± 0%          ~ (p=0.737 n=7)
Wasip1/Compile/src_encoding_ascii85.test-10    77.77Mi ± 0%     70.83Mi ± 0%     -8.92% (p=0.001 n=7)
Wasip1/Run/src_encoding_ascii85.test-10        69.21Mi ± 0%     69.21Mi ± 0%     -0.00% (p=0.001 n=7)
Wasip1/Compile/src_encoding_asn1.test-10       84.42Mi ± 0%     75.93Mi ± 0%    -10.06% (p=0.001 n=7)
Wasip1/Run/src_encoding_asn1.test-10           70.30Mi ± 0%     70.30Mi ± 0%     -0.00% (p=0.011 n=7)
Wasip1/Compile/src_encoding_base32.test-10     79.55Mi ± 0%     72.31Mi ± 0%     -9.10% (p=0.001 n=7)
Wasip1/Run/src_encoding_base32.test-10         104.4Mi ± 0%     104.4Mi ± 0%          ~ (p=0.109 n=7)
Wasip1/Compile/src_encoding_base64.test-10     79.99Mi ± 0%     72.55Mi ± 0%     -9.30% (p=0.001 n=7)
Wasip1/Run/src_encoding_base64.test-10         69.50Mi ± 0%     69.50Mi ± 0%     -0.00% (p=0.002 n=7)
Wasip1/Compile/src_encoding_binary.test-10     80.86Mi ± 0%     73.49Mi ± 0%     -9.11% (p=0.001 n=7)
Wasip1/Run/src_encoding_binary.test-10         69.78Mi ± 0%     69.78Mi ± 0%          ~ (p=0.333 n=7)
Wasip1/Compile/src_encoding_csv.test-10        79.89Mi ± 0%     72.49Mi ± 0%     -9.26% (p=0.001 n=7)
Wasip1/Run/src_encoding_csv.test-10            69.51Mi ± 0%     69.51Mi ± 0%     -0.00% (p=0.001 n=7)
Wasip1/Compile/src_encoding_gob.test-10        93.46Mi ± 0%     84.85Mi ± 0%     -9.21% (p=0.001 n=7)
Wasip1/Run/src_encoding_gob.test-10            4.784Gi ±  ∞ ¹   4.784Gi ±  ∞ ¹        ~ (p=0.524 n=4+5)
geomean                                        113.7Mi          108.3Mi          -4.78%
¹ need >= 6 samples for confidence interval at level 0.95

                                            │ old_wasip1.txt │              new_wasip1.txt              │
                                            │   allocs/op    │   allocs/op    vs base                   │
Wasip1/Compile/src_archive_tar.test-10         335.0k ± 0%     266.5k ± 0%    -20.45% (p=0.001 n=7)
Wasip1/Run/src_archive_tar.test-10             7.837k ± 0%     7.836k ± 0%          ~ (p=0.409 n=7)
Wasip1/Compile/src_bufio.test-10               243.5k ± 0%     196.1k ± 0%    -19.45% (p=0.001 n=7)
Wasip1/Run/src_bufio.test-10                   3.728k ± 0%     3.728k ± 0%          ~ (p=1.000 n=7)   ¹
Wasip1/Compile/src_bytes.test-10               254.2k ± 0%     204.6k ± 0%    -19.51% (p=0.001 n=7)
Wasip1/Run/src_bytes.test-10                   6.377k ± 0%     6.377k ± 0%          ~ (p=1.000 n=7)
Wasip1/Compile/src_context.test-10             274.4k ± 0%     222.4k ± 0%    -18.98% (p=0.001 n=7)
Wasip1/Run/src_context.test-10                 3.814k ± 1%     3.814k ± 1%          ~ (p=1.000 n=7)
Wasip1/Compile/src_encoding_ascii85.test-10    227.8k ± 0%     183.1k ± 0%    -19.63% (p=0.001 n=7)
Wasip1/Run/src_encoding_ascii85.test-10        2.707k ± 0%     2.705k ± 0%     -0.07% (p=0.001 n=7)
Wasip1/Compile/src_encoding_asn1.test-10       254.4k ± 0%     199.7k ± 0%    -21.52% (p=0.001 n=7)
Wasip1/Run/src_encoding_asn1.test-10           2.990k ± 0%     2.989k ± 0%          ~ (p=0.086 n=7)
Wasip1/Compile/src_encoding_base32.test-10     233.5k ± 0%     186.8k ± 0%    -20.01% (p=0.001 n=7)
Wasip1/Run/src_encoding_base32.test-10         2.978k ± 0%     2.972k ± 0%          ~ (p=0.070 n=7)
Wasip1/Compile/src_encoding_base64.test-10     235.7k ± 0%     187.6k ± 0%    -20.39% (p=0.001 n=7)
Wasip1/Run/src_encoding_base64.test-10         2.912k ± 0%     2.910k ± 0%     -0.07% (p=0.008 n=7)
Wasip1/Compile/src_encoding_binary.test-10     241.0k ± 0%     193.0k ± 0%    -19.91% (p=0.001 n=7)
Wasip1/Run/src_encoding_binary.test-10         3.069k ± 0%     3.069k ± 0%          ~ (p=0.583 n=7)
Wasip1/Compile/src_encoding_csv.test-10        236.2k ± 0%     188.3k ± 0%    -20.30% (p=0.001 n=7)
Wasip1/Run/src_encoding_csv.test-10            2.938k ± 0%     2.933k ± 0%     -0.17% (p=0.001 n=7)
Wasip1/Compile/src_encoding_gob.test-10        286.7k ± 0%     231.2k ± 0%    -19.37% (p=0.001 n=7)
Wasip1/Run/src_encoding_gob.test-10            10.66k ±  ∞ ²   10.66k ±  ∞ ²        ~ (p=0.524 n=4+5)
geomean                                        32.13k          28.74k         -10.56%
¹ all samples are equal
² need >= 6 samples for confidence interval at level 0.95
```


### TinyGo
```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/stdlibs
                                        │ old_tinygo.txt │            new_tinygo.txt             │
                                        │     sec/op     │    sec/op      vs base                │
TinyGo/Compile/container_heap.test-10      427.7m ± 1%     419.5m ± 2%    -1.92% (p=0.001 n=7)
TinyGo/Run/container_heap.test-10          14.33m ± 0%     14.36m ± 1%         ~ (p=0.259 n=7)
TinyGo/Compile/container_list.test-10      425.5m ± 2%     418.0m ± 0%    -1.76% (p=0.001 n=7)
TinyGo/Run/container_list.test-10          14.15m ± 1%     14.19m ± 0%         ~ (p=0.710 n=7)
TinyGo/Compile/container_ring.test-10      419.0m ± 5%     411.9m ± 1%    -1.69% (p=0.001 n=7)
TinyGo/Run/container_ring.test-10          14.19m ± 0%     14.15m ± 1%         ~ (p=0.097 n=7)
TinyGo/Compile/crypto_des.test-10          435.9m ± 1%     427.5m ± 0%    -1.94% (p=0.001 n=7)
TinyGo/Run/crypto_des.test-10              18.16m ± 1%     18.16m ± 4%         ~ (p=0.902 n=7)
TinyGo/Compile/crypto_md5.test-10          433.8m ± 1%     425.7m ± 0%    -1.88% (p=0.001 n=7)
TinyGo/Run/crypto_md5.test-10              20.44m ± 0%     20.48m ± 0%         ~ (p=0.318 n=7)
TinyGo/Compile/crypto_rc4.test-10          417.4m ± 0%     410.0m ± 1%    -1.79% (p=0.001 n=7)
TinyGo/Run/crypto_rc4.test-10              160.4m ± 0%     161.0m ± 0%         ~ (p=0.073 n=7)
TinyGo/Compile/crypto_sha1.test-10         432.5m ± 0%     425.1m ± 1%    -1.71% (p=0.001 n=7)
TinyGo/Run/crypto_sha1.test-10             15.98m ± 1%     15.96m ± 1%         ~ (p=0.710 n=7)
TinyGo/Compile/crypto_sha256.test-10       439.4m ± 0%     432.2m ± 1%    -1.64% (p=0.001 n=7)
TinyGo/Run/crypto_sha256.test-10           16.08m ± 1%     16.14m ± 1%         ~ (p=0.318 n=7)
TinyGo/Compile/crypto_sha512.test-10       440.6m ± 0%     433.1m ± 3%    -1.71% (p=0.026 n=7)
TinyGo/Run/crypto_sha512.test-10           18.77m ± 4%     18.66m ± 0%         ~ (p=0.128 n=7)
TinyGo/Compile/encoding_ascii85.test-10    431.0m ± 0%     423.7m ± 0%    -1.68% (p=0.001 n=7)
TinyGo/Run/encoding_ascii85.test-10        14.83m ± 0%     14.86m ± 2%         ~ (p=0.902 n=7)
TinyGo/Compile/encoding_base32.test-10      1.098 ± 1%      1.095 ± 1%    -0.21% (p=0.007 n=7)
TinyGo/Run/encoding_base32.test-10         85.30m ± 1%     90.91m ± 4%    +6.57% (p=0.001 n=7)
TinyGo/Compile/encoding_csv.test-10        467.7m ± 0%     462.8m ± 4%         ~ (p=0.209 n=7)
TinyGo/Run/encoding_csv.test-10            22.70m ± 1%     22.93m ± 3%    +1.03% (p=0.002 n=7)
TinyGo/Compile/encoding_hex.test-10        448.6m ± 0%     440.9m ± 0%    -1.71% (p=0.001 n=7)
TinyGo/Run/encoding_hex.test-10           10.081m ± 1%     9.986m ± 1%    -0.94% (p=0.001 n=7)
TinyGo/Compile/go_scanner.test-10          477.1m ± 0%     467.6m ± 1%    -1.99% (p=0.001 n=7)
TinyGo/Run/go_scanner.test-10              16.84m ± 1%     16.85m ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/hash.test-10                683.4m ± 2%     671.7m ± 1%    -1.72% (p=0.001 n=7)
TinyGo/Run/hash.test-10                    16.31m ± 0%     16.31m ± 1%         ~ (p=0.805 n=7)
TinyGo/Compile/hash_adler32.test-10        417.2m ± 0%     410.1m ± 3%    -1.70% (p=0.026 n=7)
TinyGo/Run/hash_adler32.test-10            24.49m ± 0%     24.71m ± 0%    +0.89% (p=0.001 n=7)
TinyGo/Compile/hash_crc64.test-10          644.9m ± 1%     637.8m ± 1%    -1.09% (p=0.001 n=7)
TinyGo/Run/hash_crc64.test-10              17.52m ± 1%     17.46m ± 1%         ~ (p=0.165 n=7)
TinyGo/Compile/hash_fnv.test-10            438.7m ± 0%     430.5m ± 2%    -1.87% (p=0.001 n=7)
TinyGo/Run/hash_fnv.test-10                14.86m ± 1%     14.77m ± 0%    -0.62% (p=0.002 n=7)
TinyGo/Compile/html.test-10                 2.193 ± 1%      2.173 ± 1%         ~ (p=0.128 n=7)
TinyGo/Run/html.test-10                    16.00m ± 2%     16.04m ± 1%         ~ (p=0.710 n=7)
TinyGo/Compile/internal_itoa.test-10       415.9m ± 4%     407.4m ± 1%    -2.04% (p=0.001 n=7)
TinyGo/Run/internal_itoa.test-10           14.32m ±  ∞ ¹   14.24m ±  ∞ ¹       ~ (p=0.800 n=4+1)
geomean                                    101.3m          100.7m         -0.64%
¹ need >= 6 samples for confidence interval at level 0.95

                                        │ old_tinygo.txt │             new_tinygo.txt             │
                                        │      B/op      │      B/op       vs base                │
TinyGo/Compile/container_heap.test-10     53.28Mi ± 0%     49.21Mi ± 0%    -7.63% (p=0.001 n=7)
TinyGo/Run/container_heap.test-10         16.63Mi ± 0%     16.63Mi ± 0%         ~ (p=0.535 n=7)
TinyGo/Compile/container_list.test-10     53.23Mi ± 0%     49.18Mi ± 0%    -7.61% (p=0.001 n=7)
TinyGo/Run/container_list.test-10         16.40Mi ± 0%     16.40Mi ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/container_ring.test-10     52.47Mi ± 0%     48.43Mi ± 0%    -7.70% (p=0.001 n=7)
TinyGo/Run/container_ring.test-10         16.30Mi ± 0%     16.30Mi ± 0%         ~ (p=0.902 n=7)
TinyGo/Compile/crypto_des.test-10         53.43Mi ± 0%     49.31Mi ± 0%    -7.70% (p=0.001 n=7)
TinyGo/Run/crypto_des.test-10             16.76Mi ± 0%     16.76Mi ± 0%         ~ (p=0.073 n=7)
TinyGo/Compile/crypto_md5.test-10         53.55Mi ± 0%     49.39Mi ± 0%    -7.76% (p=0.001 n=7)
TinyGo/Run/crypto_md5.test-10             44.97Mi ± 0%     44.97Mi ± 0%         ~ (p=0.833 n=7)
TinyGo/Compile/crypto_rc4.test-10         52.45Mi ± 0%     48.41Mi ± 0%    -7.71% (p=0.001 n=7)
TinyGo/Run/crypto_rc4.test-10             29.28Mi ± 0%     29.28Mi ± 0%         ~ (p=0.477 n=7)
TinyGo/Compile/crypto_sha1.test-10        53.76Mi ± 0%     49.63Mi ± 0%    -7.69% (p=0.001 n=7)
TinyGo/Run/crypto_sha1.test-10            17.44Mi ± 0%     17.44Mi ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/crypto_sha256.test-10      53.61Mi ± 0%     49.47Mi ± 0%    -7.72% (p=0.001 n=7)
TinyGo/Run/crypto_sha256.test-10          17.53Mi ± 0%     17.53Mi ± 0%         ~ (p=1.000 n=7)
TinyGo/Compile/crypto_sha512.test-10      53.59Mi ± 0%     49.47Mi ± 0%    -7.69% (p=0.001 n=7)
TinyGo/Run/crypto_sha512.test-10          17.82Mi ± 0%     17.82Mi ± 0%         ~ (p=0.165 n=7)
TinyGo/Compile/encoding_ascii85.test-10   53.38Mi ± 0%     49.25Mi ± 0%    -7.74% (p=0.001 n=7)
TinyGo/Run/encoding_ascii85.test-10       16.54Mi ± 0%     16.54Mi ± 0%         ~ (p=0.175 n=7)
TinyGo/Compile/encoding_base32.test-10    60.78Mi ± 0%     56.25Mi ± 0%    -7.45% (p=0.001 n=7)
TinyGo/Run/encoding_base32.test-10        23.75Mi ± 0%     23.75Mi ± 0%         ~ (p=0.682 n=7)
TinyGo/Compile/encoding_csv.test-10       54.34Mi ± 0%     49.87Mi ± 0%    -8.23% (p=0.001 n=7)
TinyGo/Run/encoding_csv.test-10           11.71Mi ± 0%     11.71Mi ± 0%         ~ (p=0.221 n=7)
TinyGo/Compile/encoding_hex.test-10       53.78Mi ± 0%     49.54Mi ± 0%    -7.88% (p=0.001 n=7)
TinyGo/Run/encoding_hex.test-10           8.264Mi ± 0%     8.263Mi ± 0%         ~ (p=0.209 n=7)
TinyGo/Compile/go_scanner.test-10         55.27Mi ± 0%     50.76Mi ± 0%    -8.16% (p=0.001 n=7)
TinyGo/Run/go_scanner.test-10             18.52Mi ± 0%     18.52Mi ± 0%         ~ (p=0.535 n=7)
TinyGo/Compile/hash.test-10               58.10Mi ± 0%     53.50Mi ± 0%    -7.93% (p=0.001 n=7)
TinyGo/Run/hash.test-10                   18.22Mi ± 0%     18.22Mi ± 0%         ~ (p=0.209 n=7)
TinyGo/Compile/hash_adler32.test-10       52.85Mi ± 0%     48.79Mi ± 0%    -7.69% (p=0.001 n=7)
TinyGo/Run/hash_adler32.test-10           21.36Mi ± 0%     21.36Mi ± 0%         ~ (p=0.318 n=7)
TinyGo/Compile/hash_crc64.test-10         57.30Mi ± 0%     53.08Mi ± 0%    -7.36% (p=0.001 n=7)
TinyGo/Run/hash_crc64.test-10             16.47Mi ± 0%     16.47Mi ± 0%    -0.00% (p=0.017 n=7)
TinyGo/Compile/hash_fnv.test-10           53.50Mi ± 0%     49.35Mi ± 0%    -7.75% (p=0.001 n=7)
TinyGo/Run/hash_fnv.test-10               16.69Mi ± 0%     16.69Mi ± 0%    +0.00% (p=0.017 n=7)
TinyGo/Compile/html.test-10               163.8Mi ± 0%     159.8Mi ± 0%    -2.45% (p=0.001 n=7)
TinyGo/Run/html.test-10                   18.69Mi ± 0%     18.69Mi ± 0%         ~ (p=0.710 n=7)
TinyGo/Compile/internal_itoa.test-10      52.37Mi ± 0%     48.35Mi ± 0%    -7.67% (p=0.001 n=7)
TinyGo/Run/internal_itoa.test-10          16.16Mi ±  ∞ ¹   16.16Mi ±  ∞ ¹       ~ (p=0.800 n=4+1)
geomean                                   32.08Mi          30.86Mi         -3.81%
¹ need >= 6 samples for confidence interval at level 0.95

                                        │ old_tinygo.txt │             new_tinygo.txt             │
                                        │   allocs/op    │   allocs/op    vs base                 │
TinyGo/Compile/container_heap.test-10     110.19k ± 0%     85.06k ± 0%    -22.80% (p=0.001 n=7)
TinyGo/Run/container_heap.test-10          374.9k ± 0%     374.9k ± 0%          ~ (p=0.869 n=7)
TinyGo/Compile/container_list.test-10     109.76k ± 0%     84.83k ± 0%    -22.71% (p=0.001 n=7)
TinyGo/Run/container_list.test-10          370.0k ± 0%     370.0k ± 0%          ~ (p=0.636 n=7)
TinyGo/Compile/container_ring.test-10     109.61k ± 0%     84.69k ± 0%    -22.73% (p=0.001 n=7)
TinyGo/Run/container_ring.test-10          367.6k ± 0%     367.6k ± 0%          ~ (p=0.213 n=7)
TinyGo/Compile/crypto_des.test-10         110.51k ± 0%     85.08k ± 0%    -23.01% (p=0.001 n=7)
TinyGo/Run/crypto_des.test-10              378.1k ± 0%     378.1k ± 0%          ~ (p=0.286 n=7)
TinyGo/Compile/crypto_md5.test-10         110.78k ± 0%     85.27k ± 0%    -23.03% (p=0.001 n=7)
TinyGo/Run/crypto_md5.test-10              393.3k ± 0%     393.3k ± 0%          ~ (p=1.000 n=7)
TinyGo/Compile/crypto_rc4.test-10         109.68k ± 0%     84.82k ± 0%    -22.67% (p=0.001 n=7)
TinyGo/Run/crypto_rc4.test-10              367.1k ± 0%     367.1k ± 0%          ~ (p=0.396 n=7)
TinyGo/Compile/crypto_sha1.test-10        110.95k ± 0%     85.47k ± 0%    -22.96% (p=0.001 n=7)
TinyGo/Run/crypto_sha1.test-10             392.7k ± 0%     392.7k ± 0%          ~ (p=0.266 n=7)
TinyGo/Compile/crypto_sha256.test-10      110.80k ± 0%     85.32k ± 0%    -23.00% (p=0.001 n=7)
TinyGo/Run/crypto_sha256.test-10           394.5k ± 0%     394.5k ± 0%          ~ (p=1.000 n=7)
TinyGo/Compile/crypto_sha512.test-10      110.87k ± 0%     85.34k ± 0%    -23.02% (p=0.001 n=7)
TinyGo/Run/crypto_sha512.test-10           397.2k ± 0%     397.2k ± 0%          ~ (p=1.000 n=7)
TinyGo/Compile/encoding_ascii85.test-10   110.44k ± 0%     84.90k ± 0%    -23.13% (p=0.001 n=7)
TinyGo/Run/encoding_ascii85.test-10        373.0k ± 0%     373.0k ± 0%          ~ (p=0.636 n=7)
TinyGo/Compile/encoding_base32.test-10    116.55k ± 0%     88.68k ± 0%    -23.91% (p=0.001 n=7)
TinyGo/Run/encoding_base32.test-10         397.6k ± 0%     397.7k ± 0%          ~ (p=0.551 n=7)
TinyGo/Compile/encoding_csv.test-10       113.67k ± 0%     86.20k ± 0%    -24.16% (p=0.001 n=7)
TinyGo/Run/encoding_csv.test-10            213.4k ± 0%     213.4k ± 0%          ~ (p=1.000 n=7)
TinyGo/Compile/encoding_hex.test-10       111.61k ± 0%     85.39k ± 0%    -23.49% (p=0.001 n=7)
TinyGo/Run/encoding_hex.test-10            178.4k ± 0%     178.4k ± 0%     -0.00% (p=0.021 n=7)
TinyGo/Compile/go_scanner.test-10         114.33k ± 0%     86.48k ± 0%    -24.37% (p=0.001 n=7)
TinyGo/Run/go_scanner.test-10              420.7k ± 0%     420.7k ± 0%          ~ (p=0.298 n=7)
TinyGo/Compile/hash.test-10               118.17k ± 0%     89.60k ± 0%    -24.17% (p=0.001 n=7)
TinyGo/Run/hash.test-10                    410.7k ± 0%     410.7k ± 0%          ~ (p=0.714 n=7)
TinyGo/Compile/hash_adler32.test-10       109.75k ± 0%     84.65k ± 0%    -22.87% (p=0.001 n=7)
TinyGo/Run/hash_adler32.test-10            368.6k ± 0%     368.6k ± 0%          ~ (p=0.147 n=7)
TinyGo/Compile/hash_crc64.test-10         113.59k ± 0%     87.48k ± 0%    -22.99% (p=0.001 n=7)
TinyGo/Run/hash_crc64.test-10              371.1k ± 0%     371.1k ± 0%          ~ (p=0.122 n=7)
TinyGo/Compile/hash_fnv.test-10           110.77k ± 0%     85.18k ± 0%    -23.11% (p=0.001 n=7)
TinyGo/Run/hash_fnv.test-10                376.0k ± 0%     376.0k ± 0%          ~ (p=0.462 n=7)
TinyGo/Compile/html.test-10                327.9k ± 0%     302.4k ± 0%     -7.79% (p=0.001 n=7)
TinyGo/Run/html.test-10                    414.3k ± 0%     414.3k ± 0%          ~ (p=0.702 n=7)
TinyGo/Compile/internal_itoa.test-10      109.25k ± 0%     84.56k ± 0%    -22.59% (p=0.001 n=7)
TinyGo/Run/internal_itoa.test-10           364.4k ±  ∞ ¹   364.4k ±  ∞ ¹        ~ (p=1.200 n=4+1)
geomean                                    205.8k          181.2k         -11.96%
¹ need >= 6 samples for confidence interval at level 0.95
```

### Compiling wazero (compiled as wasip1) itself
```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
               │  old.txt   │             new.txt              │
               │   sec/op   │   sec/op    vs base              │
Compilation-10   2.537 ± 1%   2.485 ± 0%  -2.04% (p=0.001 n=7)

               │   old.txt    │              new.txt               │
               │     B/op     │     B/op      vs base              │
Compilation-10   354.6Mi ± 0%   341.0Mi ± 0%  -3.83% (p=0.001 n=7)

               │   old.txt   │              new.txt               │
               │  allocs/op  │  allocs/op   vs base               │
Compilation-10   694.6k ± 0%   606.8k ± 0%  -12.64% (p=0.001 n=7)
```


Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-03 17:00:10 -07:00
Takeshi Yoneda
5a2fe5b122 doc: alternate signal stack setup for c-archive or c-shared builds (#2225)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-02 15:16:43 -07:00
Takeshi Yoneda
2092c0a879 Runs the test case previously failing due to a bug in Rosseta 2 (#2224)
This case has been skipped due to a bug I found in Rosetta 2.
The bug was fixed in the latest macOS, so enable it now.

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-01 12:45:45 -07:00
Yage Hu
4201f5442a Disallow empty path on path_open (#2223)
Signed-off-by: Yage Hu <me@huyage.dev>
2024-05-29 10:22:12 +02:00
Takeshi Yoneda
d4a49031b6 cache: includes cpu features in cache keys (#2220)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-28 17:44:05 +09:00
Takeshi Yoneda
0b543f7ba4 doc: clarify WithCloseOnContextDone closes api.Module (#2221)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-28 17:35:53 +09:00
Takeshi Yoneda
c397a402ad mmap: eliminates dead flag (#2219)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-28 09:44:12 +09:00
Nuno Cruces
d34df000c5 Maps ERROR_NOT_A_REPARSE_POINT to EINVAL (#2218) 2024-05-27 22:07:38 +09:00
Takeshi Yoneda
4dfb1f5b26 Propagates api.Memory.Grow by users to ModuleEngine (#2216)
Since the introduction of optimizing compiler, the Memory.Grow by the users,
which has the different call path than memory.grow instruction, didn't propagate
the growth result onto compiler's ModuleInstance.

Fixes #2215

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-27 10:37:03 +09:00
Takeshi Yoneda
eb24363d34 ssa: empirically faster passRedundantPhiEliminationOpt (#2214)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-23 16:12:40 +09:00
Takeshi Yoneda
3383f44a8f arm64: reduces the struct size of instructions (#2213)
This makes arm64's instruction data structure smaller, and 
makes it more aligned with amd64. As a result, the compilation 
gets slightly faster and uses 10% less memory space for 
compiling wazero itself.

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
               │  old.txt   │             new.txt              │
               │   sec/op   │   sec/op    vs base              │
Compilation-10   3.444 ± 2%   3.315 ± 1%  -3.75% (p=0.001 n=7)

               │   old.txt    │              new.txt               │
               │     B/op     │     B/op      vs base              │
Compilation-10   391.2Mi ± 0%   354.7Mi ± 0%  -9.35% (p=0.001 n=7)

               │   old.txt   │              new.txt              │
               │  allocs/op  │  allocs/op   vs base              │
Compilation-10   693.3k ± 0%   695.3k ± 0%  +0.28% (p=0.001 n=7)
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-22 10:57:25 +09:00
Takeshi Yoneda
b9633563c0 ssa: simplifies basicBlock.params (#2212)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-21 15:51:41 +09:00
Takeshi Yoneda
ab0d27c180 regalloc: removes map use for less memory pressure (#2211)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-21 14:51:27 +09:00
Takeshi Yoneda
48f702e154 experimental: removes deprecated raw context keys (#2206)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-13 09:36:03 +09:00
Takeshi Yoneda
5a8a053bff Merges interpreter and wazeroir packages (#2204)
Some checks failed
Release CLI / Pre-release build (push) Has been cancelled
Release CLI / Pre-release test (macos-12) (push) Has been cancelled
Release CLI / Pre-release test (ubuntu-22.04) (push) Has been cancelled
Release CLI / Pre-release test (windows-2022) (push) Has been cancelled
Release CLI / Release (push) Has been cancelled
v1.7.2
2024-05-07 17:31:03 +09:00
Takeshi Yoneda
bc0915e051 integration test: adds memmov regression tests (#2203)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-07 14:51:21 +09:00
Takeshi Yoneda
3403dd3061 amd64: saves clobbered xmm8-xmm15 beyond runtime.memmove (#2202)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-06 15:17:07 +09:00
Takeshi Yoneda
bac8bd1f58 fuzz: adds regression case for #2198 (#2201)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-05-05 15:20:57 +09:00
Takeshi Yoneda
b7df8b1130 debug: do not include inlined sources in frame counts (#2199)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-30 17:23:46 +09:00
Takeshi Yoneda
60dbe962c1 Assumes ctx is not nil (#2196)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-24 08:42:25 +09:00
Takeshi Yoneda
1e6080ab98 compiler: uses slice instead of map for refToBinaryOffset (#2195)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-23 10:32:34 +09:00
Takeshi Yoneda
621f62d5a4 Fixes race condition in concurrent engine usage (#2194)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-22 16:10:04 +09:00
Takeshi Yoneda
7ad2b70626 Removes GOOS=js related leftovers (#2193)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-22 11:17:10 +09:00
Anuraag (Rag) Agrawal
5a9cb5aaf8 experimental: reflect custom allocated buffer capacity to internal buffer (#2189)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2024-04-17 16:48:37 +09:00
Takeshi Yoneda
faae9b62cf Removes old engine/wazevo/README.md (#2188)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-16 16:28:43 +09:00
Nuno Cruces
55f21b8678 experimental: custom memory allocator API tweaks (#2186)
Some checks failed
Release CLI / Pre-release build (push) Has been cancelled
Release CLI / Pre-release test (macos-12) (push) Has been cancelled
Release CLI / Pre-release test (ubuntu-22.04) (push) Has been cancelled
Release CLI / Pre-release test (windows-2022) (push) Has been cancelled
Release CLI / Release (push) Has been cancelled
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
v1.7.1
2024-04-16 08:45:04 +09:00
Takeshi Yoneda
e9bea5593a Updates CODEOWNERS (#2185)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-15 15:32:58 +09:00
Takeshi Yoneda
a3d0d967ab Cleanups ctxkey package (#2184)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-15 14:55:14 +09:00
Takeshi Yoneda
378956d2fd compiler(arm64): fixes B.cond offset limits (#2183)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-15 14:20:05 +09:00
Nuno Cruces
a0fbb18544 experimental: configure custom memory allocator (#2177)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2024-04-10 20:13:57 +09:00
Takeshi Yoneda
891e470b72 compiler(arm64): fixes overflow in huge executable relocations (#2181)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-10 09:59:35 +09:00
Anuraag (Rag) Agrawal
f31be308fa Fix WithSnapshotter doc to reference non-deprecated method (#2180)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2024-04-09 13:40:08 +09:00
Nuno Cruces
c6a907bb9d experimental: cleanup context keys (#2175)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2024-04-06 21:04:55 +09:00
Nuno Cruces
59faf80fcc threads: remove dead code (#2176)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2024-04-06 10:27:34 +09:00
Takeshi Yoneda
775330a1e5 Reverts the public Memory.Pages API (#2174)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-04 21:57:48 +09:00