Move function names out of Module (#3789)
* Move function names out of `Module` This commit moves function names in a module out of the `wasmtime_environ::Module` type and into separate sections stored in the final compiled artifact. Spurred on by #3787 to look at module load times I noticed that a huge amount of time was spent in deserializing this map. The `spidermonkey.wasm` file, for example, has a 3MB name section which is a lot of unnecessary data to deserialize at module load time. The names of functions are now split out into their own dedicated section of the compiled artifact and metadata about them is stored in a more compact format at runtime by avoiding a `BTreeMap` and instead using a sorted array. Overall this improves deserialize times by up to 80% for modules with large name sections since the name section is no longer deserialized at load time and it's lazily paged in as names are actually referenced. * Fix a typo * Fix compiled module determinism Need to not only sort afterwards but also first to ensure the data of the name section is consistent.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::{demangling::demangle_function_name_or_index, CompiledModule};
|
||||
use wasmtime_environ::{DefinedFuncIndex, EntityRef, Module};
|
||||
use wasmtime_environ::{DefinedFuncIndex, EntityRef};
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(all(feature = "jitdump", target_os = "linux"))] {
|
||||
@@ -52,14 +52,10 @@ impl ProfilingAgent for NullProfilerAgent {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn debug_name(module: &Module, index: DefinedFuncIndex) -> String {
|
||||
let index = module.func_index(index);
|
||||
fn debug_name(module: &CompiledModule, index: DefinedFuncIndex) -> String {
|
||||
let index = module.module().func_index(index);
|
||||
let mut debug_name = String::new();
|
||||
demangle_function_name_or_index(
|
||||
&mut debug_name,
|
||||
module.func_names.get(&index).map(|s| s.as_str()),
|
||||
index.index(),
|
||||
)
|
||||
.unwrap();
|
||||
demangle_function_name_or_index(&mut debug_name, module.func_name(index), index.index())
|
||||
.unwrap();
|
||||
debug_name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user