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

Allow to compile Wasm modules in host functions called from the Wasmi executor (take 2) #1122

Merged
merged 27 commits into from
Jul 10, 2024

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Jul 9, 2024

Closes #631.

This is another relatively naive fix for #631. It heavily refactors the CodeMap to no longer use atomics for synchronization but a global Mutex. The idea behind this is that this is the lowest we can get with simple synchronization locks. If this technique does not suffice the performance needs, we need to look elsewhere.

Benchmarks comparing this PR with main:

Rust-sourced benchmarks do not significantly regress:

image

Call-intense benchmark regress as expected:

image

Other benchmarks are also not signficantly affected:

image

This makes it possible to compile Wasm modules from host functions called from Wasm.
Copy link

codecov bot commented Jul 9, 2024

Codecov Report

Attention: Patch coverage is 41.04046% with 102 lines in your changes missing coverage. Please review.

Project coverage is 80.54%. Comparing base (3016673) to head (9e1b555).

Files Patch % Lines
crates/wasmi/src/engine/code_map.rs 31.03% 100 Missing ⚠️
crates/wasmi/src/engine/mod.rs 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1122      +/-   ##
==========================================
+ Coverage   80.51%   80.54%   +0.03%     
==========================================
  Files         271      272       +1     
  Lines       25110    25088      -22     
==========================================
- Hits        20217    20208       -9     
+ Misses       4893     4880      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Robbepop Robbepop changed the title Experiment: allow to compile Wasm modules in host functions called from the Wasmi executor (take 2) Allow to compile Wasm modules in host functions called from the Wasmi executor (take 2) Jul 10, 2024
@Robbepop
Copy link
Member Author

Due to the progress in optimizing the Mutex-based CodeMap implementation provided by this PR and only seeing performance regressions mostly for call-intense workloads (as expected) with mostly single digit percentage numbers, I am confident enough in this implementation to merge it for now with the outlook of finding a better, ideally lock-free and wait-free CodeMap data structure as a follow-up PR to hash out the performance regressions of this PR.

@Robbepop Robbepop merged commit c0f4a41 into main Jul 10, 2024
17 of 18 checks passed
@Robbepop Robbepop deleted the rf-mutex-codemap branch July 10, 2024 19:58
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 this pull request may close these issues.

Cannot compile a Wasm module from a called host function using the same Engine
1 participant