Skip to content

Commit

Permalink
benchmark: updates wazero to 1.0.0-pre.8
Browse files Browse the repository at this point in the history
This updates [wazero](https://wazero.io/) to [1.0.0-pre.8](https://github.com/tetratelabs/wazero/releases/tag/v1.0.0-pre.8)

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
  • Loading branch information
evacchi committed Feb 1, 2023
1 parent ca3ae18 commit 74c8514
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 44 deletions.
48 changes: 25 additions & 23 deletions benchmark/fbs/game_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions benchmark/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ require (
github.com/google/flatbuffers v2.0.6+incompatible
github.com/google/gofuzz v1.2.0
github.com/r3labs/diff/v3 v3.0.0
github.com/tetratelabs/wazero v1.0.0-pre.3
github.com/tetratelabs/wazero v1.0.0-pre.8
golang.org/x/crypto v0.0.0-20220513210258-46612604a0f9
golang.org/x/text v0.3.7
karmem.org v1.0.0
)

Expand Down
6 changes: 2 additions & 4 deletions benchmark/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tetratelabs/wazero v1.0.0-pre.3 h1:Z5fbogMUGcERzaQb9mQU8+yJSy0bVvv2ce3dfR4wcZg=
github.com/tetratelabs/wazero v1.0.0-pre.3/go.mod h1:M8UDNECGm/HVjOfq0EOe4QfCY9Les1eq54IChMLETbc=
github.com/tetratelabs/wazero v1.0.0-pre.8 h1:Ir82PWj79WCppH+9ny73eGY2qv+oCnE3VwMY92cBSyI=
github.com/tetratelabs/wazero v1.0.0-pre.8/go.mod h1:u8wrFmpdrykiFK0DFPiFm5a4+0RzsdmXYVtijBKqUVo=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand All @@ -29,8 +29,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
Expand Down
14 changes: 7 additions & 7 deletions benchmark/km/game_generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ public unsafe struct Vec3Viewer {
if (!reader.IsValidOffset(offset, 12)) {
return ref *(Vec3Viewer*)(nuint)_Globals.Null();
}
ref Vec3Viewer v = ref Unsafe.AsRef<Vec3Viewer>((void*)(reader.MemoryPointer + offset));
ref Vec3Viewer v = ref *(Vec3Viewer*)(reader.MemoryPointer + offset);
return ref v;
}

Expand Down Expand Up @@ -656,7 +656,7 @@ public unsafe struct WeaponDataViewer {
if (!reader.IsValidOffset(offset, 4)) {
return ref *(WeaponDataViewer*)(nuint)_Globals.Null();
}
ref WeaponDataViewer v = ref Unsafe.AsRef<WeaponDataViewer>((void*)(reader.MemoryPointer + offset));
ref WeaponDataViewer v = ref *(WeaponDataViewer*)(reader.MemoryPointer + offset);
if (!reader.IsValidOffset(offset, v.KarmemSizeOf())) {
return ref *(WeaponDataViewer*)(nuint)_Globals.Null();
}
Expand Down Expand Up @@ -713,7 +713,7 @@ public unsafe struct WeaponViewer {
if (!reader.IsValidOffset(offset, 4)) {
return ref *(WeaponViewer*)(nuint)_Globals.Null();
}
ref WeaponViewer v = ref Unsafe.AsRef<WeaponViewer>((void*)(reader.MemoryPointer + offset));
ref WeaponViewer v = ref *(WeaponViewer*)(reader.MemoryPointer + offset);
return ref v;
}

Expand Down Expand Up @@ -752,7 +752,7 @@ public unsafe struct MonsterDataViewer {
if (!reader.IsValidOffset(offset, 4)) {
return ref *(MonsterDataViewer*)(nuint)_Globals.Null();
}
ref MonsterDataViewer v = ref Unsafe.AsRef<MonsterDataViewer>((void*)(reader.MemoryPointer + offset));
ref MonsterDataViewer v = ref *(MonsterDataViewer*)(reader.MemoryPointer + offset);
if (!reader.IsValidOffset(offset, v.KarmemSizeOf())) {
return ref *(MonsterDataViewer*)(nuint)_Globals.Null();
}
Expand All @@ -768,7 +768,7 @@ public unsafe struct MonsterDataViewer {
if (4 + 12 > this.KarmemSizeOf()) {
return ref *(Vec3Viewer*)((nuint)_Globals.Null());
}
return ref Unsafe.AsRef<Vec3Viewer>((void*)((nuint)Unsafe.AsPointer(ref this) + 4));
return ref *(Vec3Viewer*)((nuint)Unsafe.AsPointer(ref this) + 4);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public short Mana() {
Expand Down Expand Up @@ -894,7 +894,7 @@ public unsafe struct MonsterViewer {
if (!reader.IsValidOffset(offset, 4)) {
return ref *(MonsterViewer*)(nuint)_Globals.Null();
}
ref MonsterViewer v = ref Unsafe.AsRef<MonsterViewer>((void*)(reader.MemoryPointer + offset));
ref MonsterViewer v = ref *(MonsterViewer*)(reader.MemoryPointer + offset);
return ref v;
}

Expand All @@ -919,7 +919,7 @@ public unsafe struct MonstersViewer {
if (!reader.IsValidOffset(offset, 4)) {
return ref *(MonstersViewer*)(nuint)_Globals.Null();
}
ref MonstersViewer v = ref Unsafe.AsRef<MonstersViewer>((void*)(reader.MemoryPointer + offset));
ref MonstersViewer v = ref *(MonstersViewer*)(reader.MemoryPointer + offset);
if (!reader.IsValidOffset(offset, v.KarmemSizeOf())) {
return ref *(MonstersViewer*)(nuint)_Globals.Null();
}
Expand Down
16 changes: 8 additions & 8 deletions benchmark/main_wasi_wazero.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func initBridge(b interface {
envBuilder := w.runtime.NewHostModuleBuilder("env")
emscripten.NewFunctionExporter().ExportFunctions(envBuilder)
assemblyscript.NewFunctionExporter().ExportFunctions(envBuilder)
_, err = envBuilder.Instantiate(context.Background(), w.runtime)
_, err = envBuilder.Instantiate(context.Background())
if err != nil {
b.Fatal(err)
}
Expand All @@ -61,22 +61,22 @@ func initBridge(b interface {
b.Fatal(err)
}

if _, ok := w.mainModule.Memory().Read(nil, uint32(input[0]), uint32(len(InputMemory))); !ok {
if _, ok := w.mainModule.Memory().Read(uint32(input[0]), uint32(len(InputMemory))); !ok {
b.Fatal("invalid ptr", input)
}

w.mainModule.Memory().Write(context.Background(), uint32(input[0]), make([]byte, len(InputMemory)))
w.mainModule.Memory().Write(uint32(input[0]), make([]byte, len(InputMemory)))

output, err := w.mainModule.ExportedFunction("OutputMemoryPointer").Call(context.Background())
if err != nil {
b.Fatal(err)
}

if _, ok := w.mainModule.Memory().Read(nil, uint32(output[0]), uint32(len(InputMemory))); !ok {
if _, ok := w.mainModule.Memory().Read(uint32(output[0]), uint32(len(InputMemory))); !ok {
b.Fatal("invalid ptr", output)
}

w.mainModule.Memory().Write(context.Background(), uint32(output[0]), make([]byte, len(InputMemory)))
w.mainModule.Memory().Write(uint32(output[0]), make([]byte, len(InputMemory)))

if len(input) == 0 || len(output) == 0 || input[0] == 0 || output[0] == 0 {
b.Fatal("invalid ptr", input, output)
Expand All @@ -103,19 +103,19 @@ type WasmWazero struct {
}

func (w *WasmWazero) Write(b []byte) bool {
return w.mainModule.Memory().Write(context.Background(), uint32(w.input), b)
return w.mainModule.Memory().Write(uint32(w.input), b)
}

func (w *WasmWazero) Reader(l uint32) []byte {
out, ok := w.mainModule.Memory().Read(context.Background(), uint32(w.output), l)
out, ok := w.mainModule.Memory().Read(uint32(w.output), l)
if !ok {
return nil
}
return out
}

func (w *WasmWazero) ReaderReset(b []byte) {
w.mainModule.Memory().Write(context.Background(), uint32(w.output), b)
w.mainModule.Memory().Write(uint32(w.output), b)
}

func (w *WasmWazero) Run(s Functions, v ...uint64) ([]uint64, error) {
Expand Down

0 comments on commit 74c8514

Please sign in to comment.