Skip to content

Commit

Permalink
chore: bump wazero version (#64)
Browse files Browse the repository at this point in the history
Opening this up as a draft for now for discussion. 

This PR brings `wazero` up to the latest version, which introduces their
new optimizing compiler. I've added benchmarks from the current version
we use `v1.3.0`, and the latest `v1.7.3`:


`v1.3.0`:

```
goos: linux
goarch: amd64
pkg: github.com/extism/go-sdk
cpu: 12th Gen Intel(R) Core(TM) i7-1255U
BenchmarkInitialize/noop-12                  314           3610336 ns/op         2850623 B/op       2744 allocs/op
BenchmarkInitializeWithCache/noop-12                2060            549867 ns/op         1630131 B/op       1554 allocs/op
BenchmarkNoop/noop-12                             245217              4664 ns/op           26216 B/op         22 allocs/op
BenchmarkReplace/8192-12                            5328            249861 ns/op          32.79 MB/s       34408 B/op         23 allocs/op
BenchmarkReplace/16383-12                           2366            495646 ns/op          33.06 MB/s       42600 B/op         23 allocs/op
BenchmarkReplace/32768-12                           1046           1110322 ns/op          29.51 MB/s       58985 B/op         23 allocs/op
BenchmarkReplace/empty-12                         222662              4755 ns/op           26216 B/op         22 allocs/op
BenchmarkReplace/2048-12                           17350             66603 ns/op          30.75 MB/s       28264 B/op         23 allocs/op
BenchmarkReplace/4096-12                            9249            122996 ns/op          33.30 MB/s       30312 B/op         23 allocs/op

```


`v1.7.3`:
```
goos: linux
goarch: amd64
pkg: github.com/extism/go-sdk
cpu: 12th Gen Intel(R) Core(TM) i7-1255U
BenchmarkInitialize/noop-14                          158           7486412 ns/op         5319317 B/op       6911 allocs/op
BenchmarkInitializeWithCache/noop-14                2560            473021 ns/op         1851399 B/op       1806 allocs/op
BenchmarkNoop/noop-14                             141536              7226 ns/op           70139 B/op         23 allocs/op
BenchmarkReplace/16383-14                           4167            283178 ns/op          57.86 MB/s       86535 B/op         24 allocs/op
BenchmarkReplace/32768-14                           1978            604613 ns/op          54.20 MB/s      102923 B/op         24 allocs/op
BenchmarkReplace/empty-14                         161700              6700 ns/op           70134 B/op         23 allocs/op
BenchmarkReplace/2048-14                           28716             41730 ns/op          49.08 MB/s       72199 B/op         24 allocs/op
BenchmarkReplace/4096-14                           16026             74786 ns/op          54.77 MB/s       74245 B/op         24 allocs/op
BenchmarkReplace/8192-14                            7995            144315 ns/op          56.76 MB/s       78339 B/op         24 allocs/op

```

---------

Co-authored-by: zach <[email protected]>
  • Loading branch information
nilslice and zshipko authored Jun 12, 2024
1 parent 9101916 commit 7d5e112
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions extism_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ func TestEnableExperimentalFeature(t *testing.T) {
var buf bytes.Buffer

// Set context to one that has an experimental listener
ctx := context.WithValue(context.Background(), experimental.FunctionListenerFactoryKey{}, logging.NewLoggingListenerFactory(&buf))
ctx := experimental.WithFunctionListenerFactory(context.Background(), logging.NewHostLoggingListenerFactory(&buf, logging.LogScopeAll))

manifest := manifest("sleep.wasm")
manifest.Config["duration"] = "0" // sleep for 0 seconds
Expand All @@ -790,7 +790,7 @@ func TestEnableExperimentalFeature(t *testing.T) {
defer plugin.Close()

var buf2 bytes.Buffer
ctx = context.WithValue(context.Background(), experimental.FunctionListenerFactoryKey{}, logging.NewLoggingListenerFactory(&buf2))
ctx = experimental.WithFunctionListenerFactory(context.Background(), logging.NewHostLoggingListenerFactory(&buf2, logging.LogScopeAll))
exit, out, err := plugin.CallWithContext(ctx, "run_test", []byte{})

if assertCall(t, err, exit) {
Expand Down
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ module github.com/extism/go-sdk

go 1.20

require github.com/tetratelabs/wazero v1.3.0
require (
github.com/gobwas/glob v0.2.3
github.com/stretchr/testify v1.8.4
github.com/tetratelabs/wazero v1.7.3
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/tetratelabs/wazero v1.3.0 h1:nqw7zCldxE06B8zSZAY0ACrR9OH5QCcPwYmYlwtcwtE=
github.com/tetratelabs/wazero v1.3.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
github.com/tetratelabs/wazero v1.7.3 h1:PBH5KVahrt3S2AHgEjKu4u+LlDbbk+nsGE3KLucy6Rw=
github.com/tetratelabs/wazero v1.7.3/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit 7d5e112

Please sign in to comment.