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

improving wasm_loader_get_const_offset #3969

Open
sjamesr opened this issue Dec 19, 2024 · 1 comment · May be fixed by #3976
Open

improving wasm_loader_get_const_offset #3969

sjamesr opened this issue Dec 19, 2024 · 1 comment · May be fixed by #3976

Comments

@sjamesr
Copy link
Contributor

sjamesr commented Dec 19, 2024

Hi all,

I've noticed wasm_loader_get_const_offset appearing in some of our benchmarks for module loading. This function does a linear search of the currently known constants to generate an offset in the constant table. If none is found, a new constant is added.

If I'm not mistaken, this ends up doing a linear search for every i32.const, i64.const, etc. If there are n such instructions, this becomes O(n^2) in module loading.

What if the loader maintained a hashmap of const -> offset alongside the constant table? This would allow testing presence of constants to be done much more quickly, at the expense of some memory.

What do you think?

@lum1n0us
Copy link
Collaborator

#3976

@lum1n0us lum1n0us linked a pull request Dec 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants