-
Notifications
You must be signed in to change notification settings - Fork 286
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
Optimize host calls in the wasmi interpreter #291
Conversation
This commit does two things to speed-up host calls: - Reuse heap allocations for consecutive host calls to hold arguments. - More efficient copying of stack values to host argument buffer.
Codecov Report
@@ Coverage Diff @@
## master #291 +/- ##
==========================================
- Coverage 80.02% 79.56% -0.46%
==========================================
Files 30 31 +1
Lines 4696 4738 +42
==========================================
+ Hits 3758 3770 +12
- Misses 938 968 +30
Continue to review full report at Codecov.
|
Added benchmarks in 1455e9a. Run the benchmark using:
Before
After
So we can measure a speed-up of roughly 42% for the benchmark. |
/// # Panics | ||
/// | ||
/// If the value stack does not have at least `depth` stack entries. | ||
pub fn pop_as_slice(&mut self, depth: usize) -> &[RuntimeValueInternal] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest removing the as
here. In my mind that means returning the whole thing as slice and not only parts of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, will do this!
This commit does two things to speed-up host calls:
This optimization was carved out from #287 and it would be nice to have it included so that both
v0
andv1
implementation have a more comparable performance oncewasmi
benchmarks are more precise.Benchmarks
No noticeable performance impact was measured, however, that's mainly because the current set of benchmarks do not cover the particular scenario of performing lots of host function calls.
Before
After