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: time wasmer deserialization costs #4060

Merged
merged 2 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions runtime/near-vm-runner/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ pub mod wasmer0_cache {
key: &CryptoHash,
cache: &dyn CompiledContractCache,
) -> Result<wasmer_runtime::Module, VMError> {
let _span = tracing::info_span!("compile_and_serialize_wasmer");

let module = compile_module(wasm_code, config).map_err(|e| cache_error(e, &key, cache))?;
let artifact = module
.cache()
Expand All @@ -117,6 +119,8 @@ pub mod wasmer0_cache {
fn deserialize_wasmer(
serialized: &[u8],
) -> Result<Result<wasmer_runtime::Module, VMError>, CacheError> {
let _span = tracing::info_span!("deserialize_wasmer");

let record = CacheRecord::try_from_slice(serialized).map_err(|_e| DeserializationError)?;
let serialized_artifact = match record {
CacheRecord::Error(err) => return Ok(Err(err)),
Expand Down Expand Up @@ -220,6 +224,8 @@ pub mod wasmer1_cache {
cache: &dyn CompiledContractCache,
store: &wasmer::Store,
) -> Result<wasmer::Module, VMError> {
let _span = tracing::info_span!("compile_and_serialize_wasmer1");

let module = compile_module_wasmer1(wasm_code, config, store)
.map_err(|e| cache_error(e, &key, cache))?;
let code = module
Expand All @@ -234,6 +240,8 @@ pub mod wasmer1_cache {
serialized: &[u8],
store: &wasmer::Store,
) -> Result<Result<wasmer::Module, VMError>, CacheError> {
let _span = tracing::info_span!("deserialize_wasmer1");

let record = CacheRecord::try_from_slice(serialized).map_err(|_e| DeserializationError)?;
let serialized_module = match record {
CacheRecord::Error(err) => return Ok(Err(err)),
Expand Down
6 changes: 5 additions & 1 deletion runtime/near-vm-runner/src/wasmer_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ pub fn run_wasmer<'a>(
return (None, Some(e));
}

match module.instantiate(&import_object) {
let instantiate = {
let _span = tracing::info_span!("run_wasmer/instantiate").entered();
module.instantiate(&import_object)
};
match instantiate {
Ok(instance) => {
let _span = tracing::info_span!("run_wasmer/call").entered();

Expand Down