extism / go-sdk

Extism Go SDK - easily run WebAssembly modules in your Go applications
https://pkg.go.dev/github.com/extism/go-sdk
BSD 3-Clause "New" or "Revised" License
85 stars 10 forks source link

feat: compilation cache #43

Closed mhmd-azeez closed 11 months ago

mhmd-azeez commented 11 months ago

This PR is related to https://github.com/extism/extism/pull/605

PS D:\dylibso\go-sdk> go test -benchmem -run=^$ -bench .
goos: windows
goarch: amd64
pkg: github.com/extism/go-sdk
cpu: 13th Gen Intel(R) Core(TM) i7-1365U
BenchmarkInitialize/noop-12                         385           3051739 ns/op         2942236 B/op       2751 allocs/op
BenchmarkInitializeWithCache/noop-12                2112            504269 ns/op         1686493 B/op       1554 allocs/op

Without using compilation cache: 3ms with compilation cache: 0.5ms

Since we're already exposing wazero.RuntimeConfig, I think we just need to mention it in the README

nilslice commented 11 months ago

Great work! I'm curious what the lift would be pre 1.0 to actually change the SDK API to make it so we don't actually expose any wazero functions or package info -- instead we add some configuration functions to our API that set thing in wazero.

Just as we don't expose anything wasmtime related in the Rust SDK.. if it's a massive change that would also be good to know.

mhmd-azeez commented 11 months ago

@nilslice Currently we are exposing these wazero APIs:

It all comes down to how many of these we want to implement for 1.0, maybe we can start with a minimal number of these implemented and then add them as people ask for them.

I think I can squeeze these in before December 4th: