stacks-network / stacks-core

The Stacks blockchain implementation
https://docs.stacks.co
GNU General Public License v3.0
3.01k stars 672 forks source link

feat(wasm): use only one `Engine` per global context #5447

Closed ureeves closed 1 week ago

ureeves commented 1 week ago

Instantiating a wasmtime::Engine is an expensive operation, so it is best to do it only once for the duration of a GlobalContext. Cloning an engine is, however, not an expensive operation (just an Arc::clone) and we use it to avoid referring to the global context already referred to by the instantiated ClarityWasmContext.

See-also: https://github.com/stacks-network/clarity-wasm/issues/468

obycode commented 1 week ago

I think this is a definite improvement, but does not yet close https://github.com/stacks-network/clarity-wasm/issues/468. For that issue, I'd like to go further and link in the callee contract into the current Wasm instance to call the function directly, rather than leaving Wasm and passing through Rust to go back to Wasm.

obycode commented 1 week ago

I added a diagram in the issue to help clarify.

blockstack-devops commented 2 days ago

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.