Skip to content

Commit

Permalink
benchmark: bumps vs tests wasmtime and wasmedge to latest (#1097)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
codefromthecrypt authored Feb 3, 2023
1 parent f719b49 commit e55ac9b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
# The version here is coupled to internal/integration_test/go.mod, but it
# isn't always the same as sometimes the Go layer has a broken release.
env:
WASMEDGE_VERSION: 0.11.1
WASMEDGE_VERSION: 0.11.2

- uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion internal/integration_test/vs/wasmedge/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/tetratelabs/wazero/internal/integration_test/vs/wasmedge
go 1.17

require (
github.com/second-state/WasmEdge-go v0.11.1
github.com/second-state/WasmEdge-go v0.11.2
github.com/tetratelabs/wazero v0.0.0
)

Expand Down
4 changes: 2 additions & 2 deletions internal/integration_test/vs/wasmedge/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/second-state/WasmEdge-go v0.11.1 h1:ggf9mFJrnx+eD/7bQf3vF8hYVyCMTzXTXi2MNKljhC8=
github.com/second-state/WasmEdge-go v0.11.1/go.mod h1:HyBf9hVj1sRAjklsjc1Yvs9b5RcmthPG9z99dY78TKg=
github.com/second-state/WasmEdge-go v0.11.2 h1:4RZhxKvay9uBM9uzE0jrB/26t1ncQG3LbNQOooKjrHA=
github.com/second-state/WasmEdge-go v0.11.2/go.mod h1:HyBf9hVj1sRAjklsjc1Yvs9b5RcmthPG9z99dY78TKg=
2 changes: 1 addition & 1 deletion internal/integration_test/vs/wasmtime/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/tetratelabs/wazero/internal/integration_test/vs/wasmtime
go 1.17

require (
github.com/bytecodealliance/wasmtime-go v1.0.0
github.com/bytecodealliance/wasmtime-go/v5 v5.0.0
github.com/tetratelabs/wazero v0.0.0
)

Expand Down
4 changes: 2 additions & 2 deletions internal/integration_test/vs/wasmtime/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/bytecodealliance/wasmtime-go v1.0.0 h1:9u9gqaUiaJeN5IoD1L7egD8atOnTGyJcNp8BhkL9cUU=
github.com/bytecodealliance/wasmtime-go v1.0.0/go.mod h1:jjlqQbWUfVSbehpErw3UoWFndBXRRMvfikYH6KsCwOg=
github.com/bytecodealliance/wasmtime-go/v5 v5.0.0 h1:Ue3eBDElMrdzWoUtr7uPr7NeDZriuR5oIivp5EHknQU=
github.com/bytecodealliance/wasmtime-go/v5 v5.0.0/go.mod h1:KcecyOqumZrvLnlaEIMFRbBaQeUYNvsbPjAEVho1Fcs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
64 changes: 32 additions & 32 deletions internal/integration_test/vs/wasmtime/wasmtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"context"
"fmt"

"github.com/bytecodealliance/wasmtime-go"
wt "github.com/bytecodealliance/wasmtime-go/v5"

"github.com/tetratelabs/wazero/internal/integration_test/vs"
)
Expand All @@ -16,86 +16,86 @@ func newWasmtimeRuntime() vs.Runtime {
}

type wasmtimeRuntime struct {
engine *wasmtime.Engine
module *wasmtime.Module
engine *wt.Engine
module *wt.Module
}

type wasmtimeModule struct {
store *wasmtime.Store
store *wt.Store
// instance is here because there's no close/destroy function. The only thing is garbage collection.
instance *wasmtime.Instance
funcs map[string]*wasmtime.Func
instance *wt.Instance
funcs map[string]*wt.Func
logFn func([]byte) error
mem *wasmtime.Memory
mem *wt.Memory
}

func (r *wasmtimeRuntime) Name() string {
return "wasmtime"
}

func (m *wasmtimeModule) log(_ *wasmtime.Caller, args []wasmtime.Val) ([]wasmtime.Val, *wasmtime.Trap) {
func (m *wasmtimeModule) log(_ *wt.Caller, args []wt.Val) ([]wt.Val, *wt.Trap) {
unsafeSlice := m.mem.UnsafeData(m.store)
offset := args[0].I32()
byteCount := args[1].I32()
if err := m.logFn(unsafeSlice[offset : offset+byteCount]); err != nil {
return nil, wasmtime.NewTrap(err.Error())
return nil, wt.NewTrap(err.Error())
}
return []wasmtime.Val{}, nil
return []wt.Val{}, nil
}

func (r *wasmtimeRuntime) Compile(_ context.Context, cfg *vs.RuntimeConfig) (err error) {
r.engine = wasmtime.NewEngine()
if r.module, err = wasmtime.NewModule(r.engine, cfg.ModuleWasm); err != nil {
r.engine = wt.NewEngine()
if r.module, err = wt.NewModule(r.engine, cfg.ModuleWasm); err != nil {
return
}
return
}

func (r *wasmtimeRuntime) Instantiate(_ context.Context, cfg *vs.RuntimeConfig) (mod vs.Module, err error) {
wm := &wasmtimeModule{funcs: map[string]*wasmtime.Func{}}
wm := &wasmtimeModule{funcs: map[string]*wt.Func{}}

// We can't reuse a store because even if we call close, re-instantiating too many times leads to:
// >> resource limit exceeded: instance count too high at 10001
wm.store = wasmtime.NewStore(r.engine)
linker := wasmtime.NewLinker(wm.store.Engine)
wm.store = wt.NewStore(r.engine)
linker := wt.NewLinker(wm.store.Engine)

// Instantiate WASI, if configured.
if cfg.NeedsWASI {
if err = linker.DefineWasi(); err != nil {
return
}
config := wasmtime.NewWasiConfig() // defaults to toss stdout
config.InheritStderr() // see errors
config := wt.NewWasiConfig() // defaults to toss stdout
config.InheritStderr() // see errors
wm.store.SetWasi(config)
}

// Instantiate the host module, "env", if configured.
if cfg.LogFn != nil {
wm.logFn = cfg.LogFn
if err = linker.Define("env", "log", wasmtime.NewFunc(
if err = linker.Define("env", "log", wt.NewFunc(
wm.store,
wasmtime.NewFuncType(
[]*wasmtime.ValType{
wasmtime.NewValType(wasmtime.KindI32),
wasmtime.NewValType(wasmtime.KindI32),
wt.NewFuncType(
[]*wt.ValType{
wt.NewValType(wt.KindI32),
wt.NewValType(wt.KindI32),
},
[]*wasmtime.ValType{},
[]*wt.ValType{},
),
wm.log,
)); err != nil {
return
}
} else if cfg.EnvFReturnValue != 0 {
ret := []wasmtime.Val{wasmtime.ValI64(int64(cfg.EnvFReturnValue))}
if err = linker.Define("env", "f", wasmtime.NewFunc(
ret := []wt.Val{wt.ValI64(int64(cfg.EnvFReturnValue))}
if err = linker.Define("env", "f", wt.NewFunc(
wm.store,
wasmtime.NewFuncType(
[]*wasmtime.ValType{
wasmtime.NewValType(wasmtime.KindI64),
wt.NewFuncType(
[]*wt.ValType{
wt.NewValType(wt.KindI64),
},
[]*wasmtime.ValType{wasmtime.NewValType(wasmtime.KindI64)},
[]*wt.ValType{wt.NewValType(wt.KindI64)},
),
func(_ *wasmtime.Caller, args []wasmtime.Val) ([]wasmtime.Val, *wasmtime.Trap) {
func(_ *wt.Caller, args []wt.Val) ([]wt.Val, *wt.Trap) {
return ret, nil
},
)); err != nil {
Expand Down Expand Up @@ -148,7 +148,7 @@ func (r *wasmtimeRuntime) Instantiate(_ context.Context, cfg *vs.RuntimeConfig)
func (r *wasmtimeRuntime) Close(context.Context) error {
r.module = nil
r.engine = nil
return nil // wasmtime only closes via finalizer
return nil // wt only closes via finalizer
}

func (m *wasmtimeModule) Memory() []byte {
Expand Down Expand Up @@ -201,5 +201,5 @@ func (m *wasmtimeModule) Close(context.Context) error {
m.store = nil
m.instance = nil
m.funcs = nil
return nil // wasmtime only closes via finalizer
return nil // wt only closes via finalizer
}

0 comments on commit e55ac9b

Please sign in to comment.