stellar / rs-soroban-env

Rust environment for Soroban contracts.
Apache License 2.0
60 stars 40 forks source link

Minimize linkage during VM instantiation #1292

Closed graydon closed 5 months ago

graydon commented 9 months ago

VM instantiation spends a third of its time defining host functions in the linker -- these are fairly atomics-heavy operations due to threadsafety in wasmi -- and this can be minimized if we filter for the host functions that a contract actually uses.

The caveat here is that in the worst case a contract could still use all host functions, so from a metering perspective we would probably have to make the instantiation costs more granular (eg. introduce a new cost type LinkVMFunction with a linear model based on the number used, or something).

graydon commented 5 months ago

Fixed by https://github.com/stellar/rs-soroban-env/pull/1359 and https://github.com/stellar/rs-soroban-env/pull/1375