Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable wasmtime caching #605

Merged
merged 15 commits into from
Nov 28, 2023
Merged

feat: enable wasmtime caching #605

merged 15 commits into from
Nov 28, 2023

Conversation

zshipko
Copy link
Contributor

@zshipko zshipko commented Nov 22, 2023

Alternate to: #596 without support for manually compiling/loading native code

  • Enables wasmtime caching: https://docs.wasmtime.dev/cli-cache.html
  • Adds EXTISM_CACHE_CONFIG and PluginBuilder::with_cache_config to determine where to load a custom cache configuration from
  • Adds PluginBuilder::with_cache_disabled to disable the cache when initializing a plugin
    • Setting EXTISM_CACHE_CONFIG="" will also disable caching

Performance

With caching:

create/create_plugin    time:   [2.9079 ms 2.9139 ms 2.9200 ms]                                  
                        change: [+3.2677% +3.6399% +3.9766%] (p = 0.00 < 0.20)
                        Change within noise threshold.

Compared to main:

create/create_plugin    time:   [26.089 ms 26.498 ms 26.923 ms]                                 
                        change: [+0.1729% +2.0868% +4.1337%] (p = 0.04 < 0.20)
                        Change within noise threshold.

@zshipko zshipko changed the title feat: support loading wasmtime compiled modules, enable wasmtime caching feat: enable wasmtime caching Nov 27, 2023
@zshipko zshipko marked this pull request as ready for review November 27, 2023 18:23
@zshipko zshipko merged commit a517cd2 into main Nov 28, 2023
5 checks passed
@zshipko zshipko deleted the wasmtime-caching branch November 28, 2023 19:50
mhmd-azeez added a commit to extism/go-sdk that referenced this pull request Dec 5, 2023
This PR is related to extism/extism#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant