Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Duplicate JIT debug module registrations with components #9461

Closed
SingleAccretion opened this issue Oct 13, 2024 · 0 comments · Fixed by #9470
Closed

Duplicate JIT debug module registrations with components #9461

SingleAccretion opened this issue Oct 13, 2024 · 0 comments · Fixed by #9470

Comments

@SingleAccretion
Copy link
Contributor

Reproduction:

  1. Compile any component, e. g.
int main()
{
    int a = 1;
    return a;
}
> & $env:WASI_SDK_PATH/bin/clang main.cpp -o main.wasm -g3 -target wasm32-unknown-wasip2
  1. Debug with lldb+wasmtime:
> lldb wasmtime -- -D debug-info -O opt-level=0 main.wasm
> (lldb) b main
> (lldb) c ; Until you reach WASM's 'main'
  1. Observe four (JIT) modules (for each core module in a component). All of them have the exact same content.
> (lldb) image list
  1. Also observe that LLDB needed to index the same DWARF info four times. This means that "startup with debugging" is 4x slower if we exclude the time to compile code and transform DWARF.

The bug is somewhere around here:

let text = self.text();
let bytes = crate::debug::create_gdbjit_image(
self.mmap().to_vec(),
(text.as_ptr(), text.len()),
)
.context("failed to create jit image for gdb")?;
let reg = crate::runtime::vm::GdbJitImageRegistration::register(bytes);
self.dbg_jit_registration = Some(reg);

AFAICT, with components, the generated image is a shared (among core modules) resource, so each Module::from_parts_raw call here:

// Convert all information about static core wasm modules into actual
// `Module` instances by converting each `CompiledModuleInfo`, the
// `types` type information, and the code memory to a runtime object.
let static_modules = static_modules
.into_iter()
.map(|(_, info)| Module::from_parts_raw(engine, code.clone(), info, false))
.collect::<Result<_>>()?;

Registers the same image.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant