Skip to content

Speed up func calls#94

Merged
jbourassa merged 1 commit intomainfrom
speedup-func-call
Dec 21, 2022
Merged

Speed up func calls#94
jbourassa merged 1 commit intomainfrom
speedup-func-call

Conversation

@jbourassa
Copy link
Copy Markdown
Collaborator

@jbourassa jbourassa commented Dec 21, 2022

  • Fetch the store context only once
  • Get rid of Vec allocation for param types, instead use the FuncType.

Before:

Calculating -------------------------------------
     Instance#invoke      2.188M (± 0.8%) i/s -     10.941M in   5.001141s
           Func#call      2.597M (± 0.7%) i/s -     13.178M in   5.075365s

After:

Calculating -------------------------------------
     Instance#invoke      2.527M (± 0.5%) i/s -     12.712M in   5.030878s
           Func#call      3.071M (± 1.0%) i/s -     15.484M in   5.042146s

This is a modest gain (~15%), but I see no downside so why not. I have a branch that speeds up by another ~17% but that required using unsafe, so I'll sit on it for now.

Wasm func call is still much slower than a regular Proc#call (by almost 2 order of magnitudes IIRC), but it's probably acceptable still. We're talking ~0.33us for Func#call if I'm doing my math right.

- Fetch the store context only once
- Get rid of Vec allocation for param types, instead use the FuncType.

Before:
```
Calculating -------------------------------------
     Instance#invoke      2.188M (± 0.8%) i/s -     10.941M in   5.001141s
           Func#call      2.597M (± 0.7%) i/s -     13.178M in   5.075365s
```

After:
```
Calculating -------------------------------------
     Instance#invoke      2.527M (± 0.5%) i/s -     12.712M in   5.030878s
           Func#call      3.071M (± 1.0%) i/s -     15.484M in   5.042146s
```
@jbourassa jbourassa marked this pull request as ready for review December 21, 2022 17:44
@jbourassa jbourassa merged commit c6db779 into main Dec 21, 2022
@jbourassa jbourassa deleted the speedup-func-call branch December 23, 2022 00:02
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