Skip to content

winch: Optimize calls#7927

Merged
saulecabrera merged 3 commits intobytecodealliance:mainfrom
saulecabrera:some-optimizations
Feb 14, 2024
Merged

winch: Optimize calls#7927
saulecabrera merged 3 commits intobytecodealliance:mainfrom
saulecabrera:some-optimizations

Conversation

@saulecabrera
Copy link
Member

@saulecabrera saulecabrera commented Feb 13, 2024

This commit introduces several optimizations to speed up the compilation of function calls:

  • Keep track of previously resolved function signatures for local or imported callees to avoid computing the ABISig on every function call.
  • Keep track of previously resolved type signatures for indirect calls to avoid computing the ABISig on every function call.
  • Refactor CallKnown and CallUnknown instructions to make the BoxCallInfo field in the struct optional. Prior to this change, from Winch's perspective each call lowering involved a heap allocation, using the default values for BoxCallInfo, which in the end are not used by Winch.
  • Switch Winch's internal Stack to use a SmallVec rather than a Vec. Many of the operations involving builtin function calls require inserting elements at arbitrary offsets in the stack and using a SmallVec makes this process more efficient.

With the changes mentioned above, I observed ~30% improvement in compilation times for modules that are call-heavy.

@saulecabrera saulecabrera requested a review from a team as a code owner February 13, 2024 17:23
@saulecabrera saulecabrera requested review from elliottt and removed request for a team February 13, 2024 17:23
@saulecabrera saulecabrera force-pushed the some-optimizations branch 2 times, most recently from 00477ff to f3421b6 Compare February 13, 2024 17:36
This commit introduces several optimizations to speed up the compilation
of function calls:

* Keep track of previously resolved function signatures for local or
  imported callees to avoid computing the `ABISig` on every
  function call.
* Keep track of previously resolved type signatures for indirect calls
  to avoid computing the `ABISig` on every function call.
* Refactor `CallKnown` and `CallUnknown` instructions to make the
  `BoxCallInfo` field in the struct optional. Prior to this change,
  from Winch's perspective each call lowering involved a heap
  allocation, using the default values for `BoxCallInfo`, which in the
  end are not used by Winch.
* Switch Winch's internal `Stack` to use a `SmallVec` rather than
  a `Vec`. Many of the operations involving builtin function calls
  require inserting elements at arbitrary offsets in the stack and
  using a `SmallVec` makes this process more efficient.

With the changes mentioned above, I observed ~30% improvement in
compilation times for modules that are call-heavy.
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen isle Related to the ISLE domain-specific language winch Winch issues or pull requests labels Feb 13, 2024
@github-actions
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen, @saulecabrera

Details This issue or pull request has been labeled: "cranelift", "cranelift:area:x64", "isle", "winch"

Thus the following users have been cc'd because of the following labels:

  • cfallin: isle
  • fitzgen: isle
  • saulecabrera: winch

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Member

@elliottt elliottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good to me!

@saulecabrera saulecabrera added this pull request to the merge queue Feb 14, 2024
Merged via the queue into bytecodealliance:main with commit 1b5c4ae Feb 14, 2024
@saulecabrera saulecabrera deleted the some-optimizations branch February 14, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language winch Winch issues or pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants