Improves instantiation performance by removing ProxyFunc (#942)
This removes ProxyFunc, which was an internal experiment to make functions that use memory to store parameters or results easier to see. The main issue with the approach was instantiation performance, as it needs to dynamically generate functions. Another approach to visibility can happen later, for example via internal logging hooks. Notably, this fixed the performance regression after switching WASI to ProxyFunc: ``` name old time/op new time/op delta Allocation/Compile-16 39.8ms ± 0% 39.5ms ± 0% -0.62% (p=0.016 n=4+5) Allocation/Instantiate-16 1.74ms ± 4% 0.86ms ± 1% -50.19% (p=0.008 n=5+5) Allocation/Call-16 4.25µs ± 1% 4.21µs ± 2% ~ (p=0.151 n=5+5) name old alloc/op new alloc/op delta Allocation/Compile-16 20.3MB ± 0% 20.3MB ± 0% ~ (p=0.841 n=5+5) Allocation/Instantiate-16 1.04MB ± 0% 0.56MB ± 0% -45.88% (p=0.008 n=5+5) Allocation/Call-16 48.0B ± 0% 48.0B ± 0% ~ (all equal) name old allocs/op new allocs/op delta Allocation/Compile-16 432k ± 0% 432k ± 0% ~ (p=0.833 n=5+5) Allocation/Instantiate-16 16.6k ± 0% 6.7k ± 0% -59.34% (p=0.008 n=5+5) Allocation/Call-16 5.00 ± 0% 5.00 ± 0% ~ (all equal) ``` Since we also removed it from `GOARCH=wasm GOOS=js`, we experienced a performance benefit there as well: ``` name old time/op new time/op delta _main/gojs.Run-16 13.7ms ± 1% 12.2ms ± 3% -10.76% (p=0.008 n=5+5) name old alloc/op new alloc/op delta _main/gojs.Run-16 25.4MB ± 0% 25.0MB ± 0% -1.66% (p=0.008 n=5+5) name old allocs/op new allocs/op delta _main/gojs.Run-16 166k ± 0% 158k ± 0% -4.79% (p=0.016 n=4+5) ``` Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -306,11 +306,6 @@ func (b *hostModuleBuilder) ExportHostFunc(fn *wasm.HostFunc) {
|
||||
b.nameToGoFunc[fn.ExportNames[0]] = fn
|
||||
}
|
||||
|
||||
// ExportProxyFunc implements wasm.ProxyFuncExporter
|
||||
func (b *hostModuleBuilder) ExportProxyFunc(fn *wasm.ProxyFunc) {
|
||||
b.nameToGoFunc[fn.Name()] = fn
|
||||
}
|
||||
|
||||
// NewFunctionBuilder implements HostModuleBuilder.NewFunctionBuilder
|
||||
func (b *hostModuleBuilder) NewFunctionBuilder() HostFunctionBuilder {
|
||||
return &hostFunctionBuilder{b: b}
|
||||
|
||||
Reference in New Issue
Block a user