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

Optimize list<u8> lifting and lowering #6971

Conversation

alexcrichton
Copy link
Member

This commit optimizes the lifting and lowering routines for list<u8> and other similar primitive integer types. The current lifting/lowering is intended to be general-purpose and correct but doesn't optimize well with LLVM for a number of reasons. I first attempted to reshape the general-purpose code to be easier for LLVM to optimize but in the end was unable to convince LLVM that various pointers here don't alias which meant that the general-purpose lowering/lifting never optimized well.

Instead, however, I've added new trait methods which are implemented the same way as the general purpose methods beforehand. The integer/primitive implementations overwrite these implementations with more specialized versions given knowledge of primitives.

On a local benchmark this makes lifting/lowering disappear from a profile since memcpy is generally much faster than per-item processing.

This commit optimizes the lifting and lowering routines for `list<u8>`
and other similar primitive integer types. The current lifting/lowering
is intended to be general-purpose and correct but doesn't optimize well
with LLVM for a number of reasons. I first attempted to reshape the
general-purpose code to be easier for LLVM to optimize but in the end
was unable to convince LLVM that various pointers here don't alias which
meant that the general-purpose lowering/lifting never optimized well.

Instead, however, I've added new trait methods which are implemented the
same way as the general purpose methods beforehand. The
integer/primitive implementations overwrite these implementations with
more specialized versions given knowledge of primitives.

On a local benchmark this makes lifting/lowering disappear from a
profile since memcpy is generally much faster than per-item processing.
@alexcrichton alexcrichton requested a review from a team as a code owner September 6, 2023 18:55
@github-actions github-actions bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Sep 6, 2023
@github-actions
Copy link

github-actions bot commented Sep 6, 2023

Subscribe to Label Action

cc @peterhuene

This issue or pull request has been labeled: "wasmtime:api"

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

  • peterhuene: wasmtime:api

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

Learn more.

Copy link
Contributor

@pchickey pchickey left a comment

Choose a reason for hiding this comment

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

Awesome!

@alexcrichton alexcrichton added this pull request to the merge queue Sep 6, 2023
Merged via the queue into bytecodealliance:main with commit 289e6af Sep 6, 2023
@alexcrichton alexcrichton deleted the opt-lift-lower-for-primitives branch September 6, 2023 22:02
eduardomourar pushed a commit to eduardomourar/wasmtime that referenced this pull request Sep 6, 2023
This commit optimizes the lifting and lowering routines for `list<u8>`
and other similar primitive integer types. The current lifting/lowering
is intended to be general-purpose and correct but doesn't optimize well
with LLVM for a number of reasons. I first attempted to reshape the
general-purpose code to be easier for LLVM to optimize but in the end
was unable to convince LLVM that various pointers here don't alias which
meant that the general-purpose lowering/lifting never optimized well.

Instead, however, I've added new trait methods which are implemented the
same way as the general purpose methods beforehand. The
integer/primitive implementations overwrite these implementations with
more specialized versions given knowledge of primitives.

On a local benchmark this makes lifting/lowering disappear from a
profile since memcpy is generally much faster than per-item processing.
alexcrichton added a commit that referenced this pull request Sep 12, 2023
This commit optimizes the lifting and lowering routines for `list<u8>`
and other similar primitive integer types. The current lifting/lowering
is intended to be general-purpose and correct but doesn't optimize well
with LLVM for a number of reasons. I first attempted to reshape the
general-purpose code to be easier for LLVM to optimize but in the end
was unable to convince LLVM that various pointers here don't alias which
meant that the general-purpose lowering/lifting never optimized well.

Instead, however, I've added new trait methods which are implemented the
same way as the general purpose methods beforehand. The
integer/primitive implementations overwrite these implementations with
more specialized versions given knowledge of primitives.

On a local benchmark this makes lifting/lowering disappear from a
profile since memcpy is generally much faster than per-item processing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:api Related to the API of the `wasmtime` crate itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants