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

Refactor Instance management within the CallStack (take 2) #1065

Merged
merged 58 commits into from
Jun 15, 2024

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Jun 14, 2024

This refactor the CallStack so that Instance is no longer part of each CallFrame.

Instead the CallStack now has a dedicated stack for Instances and only pushes to this stack in case a function call changes the currently used Instance thus significantly reducing memory consumption for large call stacks.

Furthermore this optimizes returning from functions since now the cached linear memory and global only need to be re-loaded in case the returned call actually changed the currently used Instance which is an uncommon case and thus re-loading happens less frequently in the common case, speeding up call-intense workloads.

We now have a single MemoryCache and a single GlobalCache each caching the linear memory and global variable at index 0 respectively.
The linear memory at index 0 makes sense to cache since Wasmi does not yet support multi-memory. The global at index 0 makes sense since it usually serves as the shadow stack pointer.
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 77.92208% with 17 lines in your changes missing coverage. Please review.

Project coverage is 80.50%. Comparing base (f11e850) to head (ceade4e).

Files Patch % Lines
crates/collections/src/head_vec.rs 63.63% 8 Missing ⚠️
crates/wasmi/src/engine/executor/stack/calls.rs 85.18% 4 Missing ⚠️
crates/wasmi/src/engine/executor/instrs/call.rs 80.00% 3 Missing ⚠️
crates/wasmi/src/engine/executor/mod.rs 83.33% 1 Missing ⚠️
crates/wasmi/src/engine/executor/stack/mod.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1065      +/-   ##
==========================================
- Coverage   80.51%   80.50%   -0.02%     
==========================================
  Files         268      269       +1     
  Lines       24927    24970      +43     
==========================================
+ Hits        20070    20101      +31     
- Misses       4857     4869      +12     

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

@Robbepop Robbepop changed the title Replace InstanceCache by finer grained caches Refactor Instance management within the CallStack (take 2) Jun 15, 2024
@Robbepop Robbepop merged commit 3297811 into master Jun 15, 2024
17 of 18 checks passed
@Robbepop Robbepop deleted the rf-remove-instance-cache branch June 15, 2024 10:32
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.

1 participant