Commit Graph

1328 Commits

Author SHA1 Message Date
Nuno Cruces
1353ca24fe experimental: allow custom memory allocator Reallocate to fail (#2315)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2024-09-16 10:28:30 +01:00
Edoardo Vacchi
b468adaf3d compiler: ResolveImportedFunction should infer the typeID from the importing module (#2314)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2024-09-16 10:59:41 +09:00
Nuno Cruces
5ed4c174cc ci: upgrade to Go 1.23 (#2301)
Some checks failed
Release CLI / Pre-release build (push) Has been cancelled
Release CLI / Pre-release test (macos-14) (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
2024-08-14 06:41:47 -07:00
Bjørn Erik Pedersen
a186448de5 Add experimental ImportResolver (#2298)
Closes #2294

Signed-off-by: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
2024-08-05 07:56:24 -07:00
jerbob92
c345ddf2b5 Add support for Emscripten version 3.1.57 (#2290)
This update the imports/emscripten package implementation
so that it can support v3.1.57+ which came with a breaking
change: https://github.com/emscripten-core/emscripten/pull/21555

Signed-off-by: Jeroen Bobbeldijk <jeroen@klippa.com>
2024-07-19 08:17:29 -07:00
Takeshi Yoneda
c077eabacd ci: tests with Go 1.23rc2 (#2277) 2024-07-17 22:18:10 -07:00
Takeshi Yoneda
9a19a04962 backend: stop allocating ValueDefinitions (#2288)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-07-10 10:41:22 -07:00
Takeshi Yoneda
e2db5acda7 backend: removes unnecessary ValueDefinition fields (#2287)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-07-10 09:51:09 -07:00
Takeshi Yoneda
2c53c6b5a3 ssa: removes valueIDToInstruction slice (#2286)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-07-09 17:35:23 -07:00
Takeshi Yoneda
95f37cd19f ssa: removes map use for Value aliasing (#2285)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-07-09 16:54:24 -07:00
Takeshi Yoneda
0194765782 ssa: stores types in higher 4-bits of Variable (#2284)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-07-09 09:19:13 -07:00
Takeshi Yoneda
6d8e131b65 ssa: removes unnecessary definition (#2283)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-07-09 08:57:56 -07:00
Takeshi Yoneda
e73ede5f55 Uses unsafe.String where possible (#2282)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-07-09 08:00:31 -07:00
Anuraag (Rag) Agrawal
1734cdb9d5 threads: lock around invocations of memory.Grow (#2279)
fixes #2278

Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2024-07-03 19:29:56 -07:00
Takeshi Yoneda
77222b739c ci: merges spectests into normal make test (#2273)
Previously, only specification tests are run separately
from the rest of the tests just to run in a separate
GHA workflow (named spectest) to have a badge to brag.
This used to unnecessarily use CI resources, and no need to
do so anymore.

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-27 15:41:05 -07:00
Takeshi Yoneda
f9373112f4 interpreter: removes unneeded stack walks (#2274)
This makes the interpreter's compilation faster by removing the 
unnecessary stack walks. As a result, for some binary, we observe
93% drops in the compilation performance(!) with an additional 
but negligible memory usage.

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
                      │   old.txt    │              new.txt               │
                      │    sec/op    │   sec/op     vs base               │
Compilation/wazero-10    130.1m ± 1%   124.7m ± 1%   -4.12% (p=0.002 n=6)
Compilation/zig-10      9097.2m ± 0%   549.0m ± 1%  -93.96% (p=0.002 n=6)
Compilation/zz-10         1.159 ± 5%    1.145 ± 3%   -1.20% (p=0.041 n=6)
TinyGo/Compile/container_heap.test-10     16.54m ± 1%   15.60m ± 4%  -5.66% (p=0.002 n=6)
TinyGo/Compile/container_list.test-10     16.36m ± 1%   15.42m ± 1%  -5.74% (p=0.002 n=6)
TinyGo/Compile/container_ring.test-10     16.08m ± 1%   15.17m ± 0%  -5.64% (p=0.002 n=6)
TinyGo/Compile/crypto_des.test-10         16.79m ± 1%   15.84m ± 0%  -5.68% (p=0.002 n=6)
TinyGo/Compile/crypto_md5.test-10         16.61m ± 1%   15.63m ± 0%  -5.88% (p=0.002 n=6)
TinyGo/Compile/crypto_rc4.test-10         15.93m ± 0%   15.05m ± 1%  -5.54% (p=0.002 n=6)
TinyGo/Compile/crypto_sha1.test-10        16.63m ± 0%   15.69m ± 0%  -5.66% (p=0.002 n=6)
TinyGo/Compile/crypto_sha256.test-10      17.15m ± 1%   16.13m ± 1%  -6.00% (p=0.002 n=6)
TinyGo/Compile/crypto_sha512.test-10      17.43m ± 2%   16.30m ± 1%  -6.49% (p=0.002 n=6)
TinyGo/Compile/encoding_ascii85.test-10   16.57m ± 1%   15.66m ± 1%  -5.52% (p=0.002 n=6)
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-27 09:43:47 -07:00
Takeshi Yoneda
c4516ae243 Removes integration_test/vs (#2270)
vs was introduced to bench various things including
the tests against other runtimes. However, the
cases are not representative, and also some are
just unable to build plus some are simply failing.

This removes the entire vs directory, and reduces
the maintenance burden.

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-26 10:44:51 -07:00
Takeshi Yoneda
d425b9eedc regalloc: complete de-virtualization (#2269) 2024-06-25 11:37:49 -07:00
Takeshi Yoneda
200980ef11 regalloc: removes unused Instr.AddedBeforeRegAlloc api (#2268)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-25 10:14:12 -07:00
Takeshi Yoneda
8db4d0fbc1 regalloc: simplifies findOrSpillAllocatable (#2267)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-25 09:59:23 -07:00
Takeshi Yoneda
c3c3c5f87a compiler: removes unnecessary code paths (#2266)
This removes the unnecessary code paths in a various places,
and the below is the result:

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
                      │  old.txt   │             new.txt              │
                      │   sec/op   │   sec/op    vs base              │
Compilation/wazero-10   1.634 ± 0%   1.626 ± 0%  -0.51% (p=0.002 n=6)
Compilation/zig-10      3.588 ± 0%   3.538 ± 2%       ~ (p=0.065 n=6)
Compilation/zz-10       15.25 ± 0%   14.87 ± 1%  -2.46% (p=0.002 n=6)
geomean                 4.472        4.406       -1.46%

                      │   old.txt    │              new.txt               │
                      │     B/op     │     B/op      vs base              │
Compilation/wazero-10   271.2Mi ± 0%   271.2Mi ± 0%       ~ (p=1.000 n=6)
Compilation/zig-10      596.3Mi ± 0%   596.3Mi ± 0%       ~ (p=0.699 n=6)
Compilation/zz-10       528.9Mi ± 0%   528.9Mi ± 0%       ~ (p=0.818 n=6)
geomean                 440.6Mi        440.6Mi       +0.00%

                      │   old.txt   │              new.txt              │
                      │  allocs/op  │  allocs/op   vs base              │
Compilation/wazero-10   448.5k ± 0%   448.5k ± 0%       ~ (p=0.937 n=6)
Compilation/zig-10      274.8k ± 0%   274.7k ± 0%       ~ (p=1.000 n=6)
Compilation/zz-10       618.3k ± 0%   618.4k ± 0%       ~ (p=0.818 n=6)
geomean                 423.9k        423.9k       -0.00%
```


Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-25 09:20:15 -07:00
Takeshi Yoneda
c0576bccff backend: de-virtualize regalloc (#2265)
This de-virtualize the regalloc code, and we got the overall 5% 
compilation perf improvements without runtime impact.

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
                      │  old.txt   │             new.txt              │
                      │   sec/op   │   sec/op    vs base              │
Compilation/wazero-10   1.722 ± 2%   1.636 ± 1%  -4.95% (p=0.002 n=6)
Compilation/zig-10      3.761 ± 0%   3.589 ± 0%  -4.58% (p=0.002 n=6)
Compilation/zz-10       16.03 ± 0%   15.20 ± 1%  -5.15% (p=0.002 n=6)
geomean                 4.700        4.470       -4.90%

                      │   old.txt    │              new.txt               │
                      │     B/op     │     B/op      vs base              │
Compilation/wazero-10   286.8Mi ± 0%   271.2Mi ± 0%  -5.44% (p=0.002 n=6)
Compilation/zig-10      601.7Mi ± 0%   596.2Mi ± 0%  -0.90% (p=0.002 n=6)
Compilation/zz-10       538.1Mi ± 0%   528.9Mi ± 0%  -1.72% (p=0.002 n=6)
geomean                 452.8Mi        440.6Mi       -2.71%

                      │   old.txt   │              new.txt              │
                      │  allocs/op  │  allocs/op   vs base              │
Compilation/wazero-10   448.4k ± 0%   448.4k ± 0%       ~ (p=0.699 n=6)
Compilation/zig-10      274.6k ± 0%   274.6k ± 0%       ~ (p=0.974 n=6)
Compilation/zz-10       618.3k ± 0%   618.5k ± 0%       ~ (p=0.065 n=6)
geomean                 423.8k        423.9k       +0.02%
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-25 08:49:07 -07:00
Takeshi Yoneda
78f2e9395e ssa: simplifies initializeCurrentBlockKnownBounds (#2263)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-23 13:43:45 -07:00
Takeshi Yoneda
98d6b90da2 regalloc: use less memory in liveness analysis (#2262)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-21 15:05:19 -07:00
Takeshi Yoneda
d18cca6382 regalloc: fast access to vrState (#2261)
This refactors the regalloc code and makes the access to
vrState pointers really fast and reduce the unnecessary 
function calls that cannot be inlined. As a result, overall
compilation perfomance improves +10% with a slight cost
of memory usage without any impact on the runtime performance.

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/stdlibs
                                                   │    old.txt    │              new.txt               │
                                                   │    sec/op     │   sec/op     vs base               │
Zig/Compile/test-opt.wasm-10                           3.280 ±  1%    2.976 ± 1%   -9.25% (p=0.001 n=7)
Zig/Compile/test.wasm-10                               4.078 ±  1%    3.771 ± 2%   -7.51% (p=0.001 n=7)
TinyGo/Compile/container_heap.test-10                 299.6m ±  2%   266.1m ± 1%  -11.18% (p=0.001 n=7)
TinyGo/Compile/container_list.test-10                 297.9m ±  0%   264.9m ± 0%  -11.07% (p=0.001 n=7)
TinyGo/Compile/container_ring.test-10                 292.4m ±  0%   260.8m ± 2%  -10.82% (p=0.001 n=7)
TinyGo/Compile/crypto_des.test-10                     304.9m ±  1%   270.8m ± 3%  -11.17% (p=0.001 n=7)
TinyGo/Compile/crypto_md5.test-10                     302.8m ±  0%   269.4m ± 1%  -11.02% (p=0.001 n=7)
TinyGo/Compile/crypto_rc4.test-10                     291.7m ±  0%   259.1m ± 1%  -11.18% (p=0.001 n=7)
TinyGo/Compile/crypto_sha1.test-10                    302.9m ±  2%   269.5m ± 0%  -11.04% (p=0.001 n=7)
TinyGo/Compile/crypto_sha256.test-10                  308.3m ±  1%   274.5m ± 1%  -10.97% (p=0.001 n=7)
TinyGo/Compile/crypto_sha512.test-10                  309.9m ±  0%   276.0m ± 0%  -10.95% (p=0.001 n=7)
TinyGo/Compile/encoding_ascii85.test-10               302.2m ±  1%   269.1m ± 0%  -10.94% (p=0.001 n=7)
TinyGo/Compile/encoding_base32.test-10                641.2m ±  0%   594.4m ± 0%   -7.29% (p=0.001 n=7)
TinyGo/Compile/encoding_csv.test-10                   325.8m ±  0%   289.4m ± 0%  -11.17% (p=0.001 n=7)
TinyGo/Compile/encoding_hex.test-10                   313.8m ±  1%   279.2m ± 0%  -11.05% (p=0.001 n=7)
TinyGo/Compile/go_scanner.test-10                     336.1m ±  4%   298.5m ± 0%  -11.20% (p=0.001 n=7)
TinyGo/Compile/hash.test-10                           402.6m ±  0%   363.3m ± 0%   -9.78% (p=0.001 n=7)
TinyGo/Compile/hash_adler32.test-10                   291.4m ±  2%   259.3m ± 1%  -11.00% (p=0.001 n=7)
TinyGo/Compile/hash_crc64.test-10                     378.3m ±  0%   342.2m ± 0%   -9.52% (p=0.001 n=7)
TinyGo/Compile/hash_fnv.test-10                       306.0m ±  1%   271.7m ± 1%  -11.20% (p=0.001 n=7)
TinyGo/Compile/html.test-10                            2.018 ±  1%    1.971 ± 2%   -2.32% (p=0.001 n=7)
TinyGo/Compile/internal_itoa.test-10                  288.5m ± 10%   257.8m ± 1%  -10.66% (p=0.001 n=7)
TinyGo/Compile/internal_profile.test-10               409.4m ±  1%   364.0m ± 1%  -11.08% (p=0.001 n=7)
TinyGo/Compile/math.test-10                           388.6m ±  0%   345.4m ± 1%  -11.10% (p=0.001 n=7)
TinyGo/Compile/math_cmplx.test-10                     330.9m ±  0%   294.2m ± 0%  -11.08% (p=0.001 n=7)
TinyGo/Compile/net.test-10                            343.9m ±  1%   306.5m ± 1%  -10.86% (p=0.001 n=7)
TinyGo/Compile/net_http_internal_ascii.test-10        288.2m ±  0%   256.9m ± 1%  -10.85% (p=0.001 n=7)
TinyGo/Compile/net_mail.test-10                       386.6m ±  1%   344.2m ± 0%  -10.97% (p=0.001 n=7)
TinyGo/Compile/os.test-10                             362.2m ±  0%   321.3m ± 0%  -11.31% (p=0.001 n=7)
TinyGo/Compile/path.test-10                           297.7m ±  0%   265.7m ± 0%  -10.72% (p=0.001 n=7)
TinyGo/Compile/reflect.test-10                        406.3m ±  1%   360.4m ± 1%  -11.30% (p=0.001 n=7)
TinyGo/Compile/sync.test-10                           302.8m ±  0%   269.9m ± 1%  -10.89% (p=0.001 n=7)
TinyGo/Compile/testing.test-10                        331.0m ±  3%   293.5m ± 0%  -11.31% (p=0.001 n=7)
TinyGo/Compile/testing_iotest.test-10                 315.1m ±  0%   281.5m ± 1%  -10.66% (p=0.001 n=7)
TinyGo/Compile/text_scanner.test-10                   322.0m ±  0%   286.7m ± 0%  -10.97% (p=0.001 n=7)
TinyGo/Compile/unicode.test-10                        304.7m ±  0%   271.6m ± 0%  -10.86% (p=0.001 n=7)
TinyGo/Compile/unicode_utf16.test-10                  303.9m ±  0%   271.2m ± 2%  -10.75% (p=0.001 n=7)
TinyGo/Compile/unicode_utf8.test-10                   300.8m ±  1%   268.2m ± 0%  -10.86% (p=0.001 n=7)
Wasip1/Compile/src_archive_tar.test-10                 1.869 ±  1%    1.643 ± 0%  -12.08% (p=0.001 n=7)
Wasip1/Compile/src_bufio.test-10                       1.268 ±  4%    1.115 ± 1%  -12.04% (p=0.001 n=7)
Wasip1/Compile/src_bytes.test-10                       1.307 ±  1%    1.152 ± 0%  -11.85% (p=0.001 n=7)
Wasip1/Compile/src_context.test-10                     1.407 ±  0%    1.243 ± 1%  -11.66% (p=0.001 n=7)
Wasip1/Compile/src_encoding_ascii85.test-10            1.136 ±  1%    1.002 ± 1%  -11.81% (p=0.001 n=7)
Wasip1/Compile/src_encoding_asn1.test-10               1.301 ±  0%    1.148 ± 1%  -11.80% (p=0.001 n=7)
Wasip1/Compile/src_encoding_base32.test-10             1.180 ±  1%    1.041 ± 1%  -11.80% (p=0.001 n=7)
Wasip1/Compile/src_encoding_base64.test-10             1.186 ±  0%    1.046 ± 0%  -11.76% (p=0.001 n=7)
Wasip1/Compile/src_encoding_binary.test-10             1.216 ±  0%    1.072 ± 1%  -11.88% (p=0.001 n=7)
Wasip1/Compile/src_encoding_csv.test-10                1.182 ±  0%    1.042 ± 0%  -11.81% (p=0.001 n=7)
Wasip1/Compile/src_encoding_gob.test-10                1.612 ±  0%    1.424 ± 4%  -11.69% (p=0.001 n=7)
Wasip1/Compile/src_encoding_hex.test-10                1.153 ±  0%    1.018 ± 1%  -11.70% (p=0.001 n=7)
Wasip1/Compile/src_encoding_json.test-10               3.412 ±  1%    3.013 ± 0%  -11.69% (p=0.001 n=7)
Wasip1/Compile/src_encoding_pem.test-10                1.494 ±  0%    1.319 ± 1%  -11.68% (p=0.001 n=7)
Wasip1/Compile/src_encoding_xml.test-10                1.400 ±  0%    1.236 ± 2%  -11.76% (p=0.001 n=7)
Wasip1/Compile/src_errors.test-10                      1.178 ±  0%    1.038 ± 0%  -11.83% (p=0.001 n=7)
Wasip1/Compile/src_expvar.test-10                      1.751 ±  0%    1.543 ± 0%  -11.87% (p=0.001 n=7)
Wasip1/Compile/src_flag.test-10                        1.279 ±  0%    1.127 ± 0%  -11.89% (p=0.001 n=7)
Wasip1/Compile/src_fmt.test-10                         1.291 ±  0%    1.143 ± 1%  -11.50% (p=0.001 n=7)
Wasip1/Compile/src_hash.test-10                        1.160 ±  0%    1.022 ± 0%  -11.83% (p=0.001 n=7)
Wasip1/Compile/src_hash_adler32.test-10              1170.5m ±  4%   996.2m ± 2%  -14.88% (p=0.001 n=7)
Wasip1/Compile/src_hash_crc32.test-10                  1.188 ±  0%    1.008 ± 0%  -15.17% (p=0.001 n=7)
Wasip1/Compile/src_hash_crc64.test-10                  1.136 ±  4%    1.000 ± 0%  -12.00% (p=0.001 n=7)
Wasip1/Compile/src_hash_fnv.test-10                    1.141 ±  0%    1.002 ± 0%  -12.18% (p=0.001 n=7)
Wasip1/Compile/src_hash_maphash.test-10                1.151 ±  0%    1.010 ± 0%  -12.25% (p=0.001 n=7)
Wasip1/Compile/src_io.test-10                          1.264 ±  0%    1.110 ± 0%  -12.20% (p=0.001 n=7)
Wasip1/Compile/src_io_fs.test-10                       1.248 ±  1%    1.101 ± 0%  -11.75% (p=0.001 n=7)
Wasip1/Compile/src_io_ioutil.test-10                   1.166 ±  0%    1.028 ± 1%  -11.86% (p=0.001 n=7)
Wasip1/Compile/src_log.test-10                         1.145 ±  0%    1.009 ± 0%  -11.95% (p=0.001 n=7)
Wasip1/Compile/src_log_syslog.test-10                  1.133 ±  0%    1.001 ± 0%  -11.66% (p=0.001 n=7)
Wasip1/Compile/src_maps.test-10                        1.144 ±  0%    1.010 ± 0%  -11.77% (p=0.001 n=7)
Wasip1/Compile/src_math.test-10                        1.248 ±  0%    1.102 ± 0%  -11.68% (p=0.001 n=7)
Wasip1/Compile/src_math_big.test-10                    2.368 ±  1%    2.082 ± 0%  -12.07% (p=0.001 n=7)
Wasip1/Compile/src_math_bits.test-10                   1.158 ±  0%    1.022 ± 0%  -11.71% (p=0.001 n=7)
Wasip1/Compile/src_math_cmplx.test-10                  1.176 ±  0%    1.035 ± 0%  -12.00% (p=0.001 n=7)
Wasip1/Compile/src_math_rand.test-10                   1.871 ±  1%    1.649 ± 2%  -11.88% (p=0.001 n=7)
Wasip1/Compile/src_mime.test-10                        1.237 ±  0%    1.089 ± 0%  -11.99% (p=0.001 n=7)
Wasip1/Compile/src_mime_multipart.test-10              1.412 ±  0%    1.239 ± 0%  -12.26% (p=0.001 n=7)
Wasip1/Compile/src_mime_quotedprintable.test-10        1.192 ±  0%    1.049 ± 0%  -11.96% (p=0.001 n=7)
Wasip1/Compile/src_os.test-10                          1.598 ±  0%    1.409 ± 0%  -11.82% (p=0.001 n=7)
Wasip1/Compile/src_os_exec.test-10                     3.080 ±  0%    2.706 ± 5%  -12.15% (p=0.001 n=7)
Wasip1/Compile/src_os_signal.test-10                 1121.0m ±  0%   987.4m ± 0%  -11.92% (p=0.001 n=7)
Wasip1/Compile/src_os_user.test-10                     1.151 ±  0%    1.014 ± 1%  -11.86% (p=0.001 n=7)
Wasip1/Compile/src_path.test-10                        1.138 ±  0%    1.002 ± 0%  -11.89% (p=0.001 n=7)
Wasip1/Compile/src_reflect.test-10                     2.507 ±  0%    2.215 ± 0%  -11.67% (p=0.001 n=7)
Wasip1/Compile/src_regexp.test-10                      1.348 ±  0%    1.185 ± 0%  -12.09% (p=0.001 n=7)
Wasip1/Compile/src_regexp_syntax.test-10               1.156 ±  0%    1.017 ± 0%  -12.04% (p=0.001 n=7)
Wasip1/Compile/src_runtime.test-10                     4.018 ±  0%    3.543 ± 1%  -11.83% (p=0.001 n=7)
Wasip1/Compile/src_runtime_internal_atomic.test-10     1.143 ±  0%    1.007 ± 1%  -11.86% (p=0.001 n=7)
Wasip1/Compile/src_runtime_internal_math.test-10     1120.5m ±  0%   987.9m ± 4%  -11.84% (p=0.001 n=7)
Wasip1/Compile/src_runtime_internal_sys.test-10      1120.5m ±  1%   986.7m ± 0%  -11.94% (p=0.001 n=7)
Wasip1/Compile/src_slices.test-10                      1.278 ±  0%    1.122 ± 0%  -12.19% (p=0.001 n=7)
Wasip1/Compile/src_sort.test-10                        1.201 ±  0%    1.057 ± 0%  -11.99% (p=0.001 n=7)
Wasip1/Compile/src_strconv.test-10                     1.270 ±  1%    1.118 ± 0%  -11.95% (p=0.001 n=7)
Wasip1/Compile/src_strings.test-10                     1.309 ±  0%    1.150 ± 0%  -12.11% (p=0.001 n=7)
Wasip1/Compile/src_sync.test-10                        1.302 ±  0%    1.148 ± 1%  -11.84% (p=0.001 n=7)
Wasip1/Compile/src_sync_atomic.test-10                 1.212 ±  1%    1.069 ± 0%  -11.83% (p=0.001 n=7)
Wasip1/Compile/src_syscall.test-10                   1127.6m ±  0%   997.3m ± 6%  -11.55% (p=0.001 n=7)
Wasip1/Compile/src_testing.test-10                     1.707 ±  0%    1.506 ± 0%  -11.78% (p=0.001 n=7)
Wasip1/Compile/src_testing_fstest.test-10              1.278 ±  0%    1.129 ± 0%  -11.65% (p=0.001 n=7)
Wasip1/Compile/src_testing_iotest.test-10              1.168 ±  1%    1.029 ± 0%  -11.85% (p=0.001 n=7)
Wasip1/Compile/src_testing_quick.test-10               1.183 ±  2%    1.041 ± 0%  -11.94% (p=0.001 n=7)
Wasip1/Compile/src_time.test-10                        1.990 ±  2%    1.756 ± 0%  -11.80% (p=0.001 n=7)
geomean                                               852.1m         754.8m       -11.42%
```


Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-21 12:18:32 -07:00
Takeshi Yoneda
7929b200f4 amd64: fixes lowerSqmulRoundSat (#2260)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-20 10:21:26 -07:00
Takeshi Yoneda
69c78f9b77 Prevents direct use of host functions via ExportedFunction (#2259)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-20 09:35:22 -07:00
Nuno Cruces
f902fb4d05 Revert tinygo reflect.SliceHeader specialization (#2210)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2024-06-18 13:01:46 -07:00
Takeshi Yoneda
c6ffc9edd1 regalloc: eliminates unnecessary Instr loop (#2258)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-18 11:31:57 -07:00
Takeshi Yoneda
54cee893da regalloc: simplifies livenessAnalysis/finalizeStartReg (#2256)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-17 15:23:39 -07:00
Takeshi Yoneda
c96893d691 frontend: reuses br_table tmp slice correctly (#2253)
Previously, the `tmpForBrTable` slice hadn't been
correctly reused, and this fixes it.
As a result, for br_table heavy cases, we see the huge
drop in the number of allocations:

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
                      │  old.txt   │             new.txt              │
                      │   sec/op   │   sec/op    vs base              │
Compilation/wazero-10   1.995 ± 0%   1.999 ± 1%       ~ (p=0.394 n=6)
Compilation/zig-10      4.169 ± 0%   4.168 ± 1%       ~ (p=0.589 n=6)
Compilation/zz-10       18.55 ± 0%   18.55 ± 0%       ~ (p=0.818 n=6)
geomean                 5.363        5.367       +0.06%

                      │   old.txt    │              new.txt               │
                      │     B/op     │     B/op      vs base              │
Compilation/wazero-10   286.8Mi ± 0%   285.4Mi ± 0%  -0.46% (p=0.002 n=6)
Compilation/zig-10      590.3Mi ± 0%   590.1Mi ± 0%  -0.03% (p=0.002 n=6)
Compilation/zz-10       549.4Mi ± 0%   537.7Mi ± 0%  -2.12% (p=0.002 n=6)
geomean                 453.0Mi        449.1Mi       -0.88%

                      │   old.txt   │              new.txt               │
                      │  allocs/op  │  allocs/op   vs base               │
Compilation/wazero-10   445.3k ± 0%   429.0k ± 0%   -3.66% (p=0.002 n=6)
Compilation/zig-10      273.0k ± 0%   269.6k ± 0%   -1.26% (p=0.002 n=6)
Compilation/zz-10       783.3k ± 0%   605.8k ± 0%  -22.66% (p=0.002 n=6)
geomean                 456.7k        412.2k        -9.73%
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-14 11:25:29 -07:00
Takeshi Yoneda
6d3a77e89a validation: avoids allocation per br_table (#2252)
This eliminates the allocation that previously happened
per br_table instruction during function validation.

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-14 11:11:00 -07:00
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>
2024-06-14 10:47:07 -07:00
Takeshi Yoneda
ec36887ad2 ssa: removes redundantParameterIndexToValue map (#2250)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-14 08:52:40 -07:00
Takeshi Yoneda
65650d399d ssa: reuses slices for basicBlock.params (#2247)
This replaces the basicBlock.params field with the reusable
VarLength[Value] type. As a result, the compilation starts
using less memory and allocations.

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero
                      │  old.txt   │             new.txt              │
                      │   sec/op   │   sec/op    vs base              │
Compilation/wazero-10   2.004 ± 2%   2.001 ± 0%       ~ (p=0.620 n=7)
Compilation/zig-10      4.164 ± 1%   4.174 ± 3%       ~ (p=0.097 n=7)
geomean                 2.888        2.890       +0.06%

                      │   old.txt    │              new.txt               │
                      │     B/op     │     B/op      vs base              │
Compilation/wazero-10   297.7Mi ± 0%   297.5Mi ± 0%  -0.06% (p=0.001 n=7)
Compilation/zig-10      594.0Mi ± 0%   593.9Mi ± 0%  -0.01% (p=0.001 n=7)
geomean                 420.5Mi        420.3Mi       -0.03%

                      │   old.txt   │              new.txt              │
                      │  allocs/op  │  allocs/op   vs base              │
Compilation/wazero-10   472.5k ± 0%   457.1k ± 0%  -3.25% (p=0.001 n=7)
Compilation/zig-10      277.2k ± 0%   275.7k ± 0%  -0.53% (p=0.001 n=7)
geomean                 361.9k        355.0k       -1.90%
```

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-13 13:01:58 -07:00
Takeshi Yoneda
37fea1236c Removes dead codes (#2246)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-06-12 09:35:41 -07:00
Yage Hu
8b3af37da0 wasi: path_open should accept a dir with RIGHT_FD_WRITE (#2244)
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: Yage Hu <me@huyage.dev>
2024-06-11 18:02:47 +02: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
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
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