Commit Graph

1186 Commits

Author SHA1 Message Date
Takeshi Yoneda
80452a94c3 Bulk lazy initialization of FunctionDefinitions (#1425)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-12 08:02:40 +10:00
Achille
78c35acd6e experimental: remove return value of FunctionListener.Before (#1453)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2023-05-11 11:52:10 +08:00
Crypt Keeper
16baeaab47 Adds Readdir to platform.File and removes internal use of fs.FS (#1454)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-11 10:04:34 +08:00
Achille
a105c43629 experimental: remove error parameter from FunctionListener.After (#1452)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
2023-05-11 06:48:26 +08:00
Crypt Keeper
4dd4d54cda Removes platform.Readdirnames (#1451)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-10 14:44:54 +08:00
Crypt Keeper
745f2c9d8a Adds IsNonblock SetNonblock PollRead to platform.File (#1447)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-10 08:43:54 +08:00
Takeshi Yoneda
e3b6eb94b3 gojs: reflect wasip1 change in README (#1450) 2023-05-10 10:15:49 +10:00
Thomas Pelletier
ef3d671195 experimental: split program counter and source offset resolution (#1448)
Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>
2023-05-09 13:34:01 -07:00
Achille
509827a23f experimental: optimize function listener context stack (#1445) 2023-05-09 08:10:12 -07:00
Nuno Cruces
6503e82d3c Follow unsafe rules. (#1449)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2023-05-09 15:34:08 +01:00
Achille
daad2fdb66 experimental: add FunctionListener and FunctionListenerFactory implementations (#1444)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
2023-05-09 17:03:08 +08:00
Thomas Pelletier
ed17e523ba experimental: expose source offset to Listener (#1433)
Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
2023-05-09 08:18:27 +08:00
Crypt Keeper
29c7c7667b Adds IsDir and Seek to platform.File (#1441)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-09 07:47:25 +08:00
Achille
99d45623c0 wasip1: support non-blocking mode on stdio (#1443)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
2023-05-09 06:45:04 +08:00
Nuno Cruces
2bf8abe1fe Cleanup scattered documentation TODOs. (#1442)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2023-05-08 18:04:02 +01:00
Crypt Keeper
3bf7e342c2 Adds Utimens to platform.File (#1440)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-08 11:14:28 +08:00
Crypt Keeper
76ef347b8c Adds Read and Pread to platform.File (#1439)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-08 07:54:06 +08:00
Achille
5add4dc0bf experimental: add wazerotest package (#1437) 2023-05-06 08:19:27 -07:00
Nuno Cruces
38a7a0f730 examples(allocation): ensure message outlives host call (#1436)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-05 11:21:13 +02:00
Crypt Keeper
b5198a46ff Adds AccessMode Write and Pwrite to platform.File (#1438)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-05 13:23:30 +08:00
Edoardo Vacchi
e46e803565 site: fix small mistake in TinyGo doc (#1435)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-04 16:31:39 +02:00
Crypt Keeper
5380321eea Adds Truncate to platform.File (#1428)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-04 15:07:18 +08:00
Crypt Keeper
6dd0cef551 Splits EACCES from EPERM on Windows (#1430)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-04 14:50:35 +08:00
Edoardo Vacchi
a912ea844e compiler: update RATIONALE.md for native check (#1432)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-04 07:37:13 +08:00
Crypt Keeper
e5dc733df7 Adds Path to platform.File and refactors tests (#1431)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-04 07:05:40 +08:00
Adrian Cole
cf5ebf6f6b Use require.ErrnoEquals for more precise failures
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-03 13:54:12 +08:00
Crypt Keeper
c7623db7cb Revises instructions to latest guidance from TinyGo (#1429)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Achille <achille.roussel@gmail.com>
2023-05-03 08:15:09 +08:00
Luca Burgazzoli
b2c11d8dfd examples(allocation): free memory after unmarshalling a result from the guest (#1390)
Signed-off-by: Luca Burgazzoli <lburgazzoli@gmail.com>
2023-05-03 07:01:05 +08:00
Crypt Keeper
c5871c772c Adds Datasync to platform.File (#1427)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-02 14:12:47 +08:00
Crypt Keeper
b79c45b91c Adds Sync to platform.File (#1426)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-02 13:16:50 +08:00
Achille
d5a2d3c7b4 wasip1: fix file open modes used by wasi-libc (#1421)
This extends wazero's interpretation of rights in wasi_snapshot_preview1.path_open to allow programs to open files in either read-only, write-only, or read-write mode.

Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2023-05-02 09:48:26 +08:00
Crypt Keeper
20017ca5e6 shows implementation impact of UnimplementedFile (#1424)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-02 07:31:17 +08:00
Crypt Keeper
18c793f8e6 Adds platform.File.Chmod (#1423)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-01 19:18:56 +08:00
Crypt Keeper
1047ddee78 Adds platform.File.Chown (#1422)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-01 18:32:13 +08:00
Crypt Keeper
493fe2d410 sysfs: stubs in approach to defining a new file type (#1290)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-01 12:33:40 +08:00
Takeshi Yoneda
cdaf6d41c8 interpreter: refactors around FunctionDefinition (#1420)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-05-01 12:07:47 +09:00
Takeshi Yoneda
f47b0d3362 Reduces FunctionDefinition usages (#1419)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-05-01 10:37:43 +08:00
Crypt Keeper
f3f7352584 lifts emscripten.InstantiateForModule out of experimental (#1418)
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: Adrian Cole <adrian@tetrate.io>
v1.1.0
2023-05-01 09:12:04 +08:00
Achille
974973d6f5 CONTRIBUTING.md: add bullet point about the merge process (#1416)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2023-04-30 18:05:20 -07:00
Nuno Cruces
77e8d72d67 api: adds CallWithStack to avoid allocations (#1407)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2023-05-01 08:52:40 +09:00
Thomas Pelletier
0bfb4b52eb Give Listener a read-only view of globals (#1404)
* experimental: give listener r/o view of globals

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* experimental: add global support to interpreter

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* exp: replace globals proxy with module interface

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* exp: trim down experimental.InternalModule

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Replace globals view slice with constantGlobal

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Fix tests after merge

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Address PR feedback

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Rename methods of experimental.Module

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Run make check

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Add WazeroOnlyType to constantGlobal

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

---------

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>
2023-04-29 00:07:28 -07:00
Crypt Keeper
6098f60bd1 Adds SplitCallStack for use in CallWithStack (#1414)
This adds an internal function `wasm.SplitCallStack` for use in #1407.
This is separate because the diff is a lot larger than the destination
change ;)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-29 13:28:52 +08:00
Ashley Jeffs
0dd73938eb Add Benthos to users.md (#1412) 2023-04-28 06:00:04 -07:00
Nuno Cruces
197facf7a9 Close certain api interfaces for external implementation (#1396)
This adds a new type `internalapi.WazeroOnly` which should be embedded on types users are likely to accidentally implement despite docs saying otherwise.

Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2023-04-28 15:32:32 +08:00
Takeshi Yoneda
f9f17031f9 Update the year in license (#1411)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-04-28 09:19:24 +09:00
Edoardo Vacchi
34a639b770 wasi: improve select(2) impl on Windows (#1398)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-04-28 08:36:48 +09:00
Takeshi Yoneda
c82ad896f6 ci: try enabling Windows on wasip1 test (#1406)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-04-27 16:21:02 +09:00
Takeshi Yoneda
86444c67a3 ci: run -race on PRs as well (#1408)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-27 09:54:59 +09:00
Takeshi Yoneda
867459d7d5 compiler: mmap per module instead of per function (#1377)
This changes the mmap strategy used in the compiler backend.
Previously, we used mmap syscall once per function and allocated the 
executable pages each time. Basically, mmap can only allocate the 
boundary of the page size of the underlying os. Even if the requested 
executable is smaller than the page size, the entire page is marked as 
executable and won't be reused by Go runtime. Therefore, we wasted 
roughly `(len(body)%osPageSize)*function`.

Even though we still need to align each function on 16 bytes boundary
when mmaping per module, the wasted space is much smaller than before.

The following benchmark results shows that this improves the overall 
compilation performance while showing the heap usage increased. 
However, the increased heap usage is totally offset by the hidden wasted
memory page which is not measured by Go's -benchmem.
Actually, when I did the experiments, I observed that roughly 20~30mb are
wasted on arm64 previously which is larger than the increased heap usage
in this result. More importantly, this increased heap usage is a target of GC
and should be ignorable in the long-running program vs the wasted page 
is persistent until the CompiledModule is closed.

Not only the actual compilation time, the result indicates that this could 
improve the overall Go runtime's performance maybe thanks to not abusing
runtime.Finalizer since you can see this improves the subsequent interpreter 
benchmark results.

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/bench
                                   │   old.txt   │              new.txt              │
                                   │   sec/op    │   sec/op     vs base              │
Compilation_sqlite3/compiler-10      183.4m ± 0%   175.9m ± 2%  -4.10% (p=0.001 n=7)
Compilation_sqlite3/interpreter-10   61.59m ± 0%   59.57m ± 0%  -3.29% (p=0.001 n=7)
geomean                              106.3m        102.4m       -3.69%

                                   │   old.txt    │               new.txt               │
                                   │     B/op     │     B/op      vs base               │
Compilation_sqlite3/compiler-10      42.93Mi ± 0%   54.33Mi ± 0%  +26.56% (p=0.001 n=7)
Compilation_sqlite3/interpreter-10   51.75Mi ± 0%   51.75Mi ± 0%   -0.01% (p=0.001 n=7)
geomean                              47.13Mi        53.02Mi       +12.49%

                                   │   old.txt   │              new.txt              │
                                   │  allocs/op  │  allocs/op   vs base              │
Compilation_sqlite3/compiler-10      26.07k ± 0%   26.06k ± 0%       ~ (p=0.149 n=7)
Compilation_sqlite3/interpreter-10   13.90k ± 0%   13.90k ± 0%       ~ (p=0.421 n=7)
geomean                              19.03k        19.03k       -0.02%


goos: linux
goarch: amd64
pkg: github.com/tetratelabs/wazero/internal/integration_test/bench
cpu: AMD Ryzen 9 3950X 16-Core Processor
                                   │   old.txt   │              new.txt               │
                                   │   sec/op    │   sec/op     vs base               │
Compilation_sqlite3/compiler-32      384.4m ± 2%   373.0m ± 4%   -2.97% (p=0.001 n=7)
Compilation_sqlite3/interpreter-32   86.09m ± 4%   65.05m ± 2%  -24.44% (p=0.001 n=7)
geomean                              181.9m        155.8m       -14.38%

                                   │   old.txt    │               new.txt               │
                                   │     B/op     │     B/op      vs base               │
Compilation_sqlite3/compiler-32      49.40Mi ± 0%   59.91Mi ± 0%  +21.29% (p=0.001 n=7)
Compilation_sqlite3/interpreter-32   51.77Mi ± 0%   51.76Mi ± 0%   -0.02% (p=0.001 n=7)
geomean                              50.57Mi        55.69Mi       +10.12%

                                   │   old.txt   │              new.txt              │
                                   │  allocs/op  │  allocs/op   vs base              │
Compilation_sqlite3/compiler-32      28.70k ± 0%   28.70k ± 0%       ~ (p=0.925 n=7)
Compilation_sqlite3/interpreter-32   14.00k ± 0%   14.00k ± 0%  -0.04% (p=0.010 n=7)
geomean                              20.05k        20.04k       -0.02%
```

resolves #1060 

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-26 14:11:37 +09:00
Takeshi Yoneda
557c340b2f ci: cleanup GOOS=wasip1 (#1405)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-26 11:53:35 +09:00