-
Notifications
You must be signed in to change notification settings - Fork 12
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
fix slow compilation by using dynasm VecAssembler #71
Conversation
This is awesome. We knew using a VecAssembler could be more optimal, but we didn't measure by how much... so great work! |
2681: fix singlepass slow compilation of many function wasm by using dynasm VecAssembler r=syrusakbary a=ailisp <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> We found in certain benchmark (a wasm with 150_000 no-op functions), compilation is slowed down by dynasmrt's mmapand mprotect syscalls, however, those mmap isn't used in wasmer and can be replaced by simpler VecAssembler. In this [bench](near/wasmer#71) it's a 10x speedup in singlepass backend compilation time. # Review - [ ] Add a short description of the change to the CHANGELOG.md file Co-authored-by: Bo Yao <[email protected]>
@matklad ptal :) |
2681: fix singlepass slow compilation of many function wasm by using dynasm VecAssembler r=ptitSeb a=ailisp <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> We found in certain benchmark (a wasm with 150_000 no-op functions), compilation is slowed down by dynasmrt's mmapand mprotect syscalls, however, those mmap isn't used in wasmer and can be replaced by simpler VecAssembler. In this [bench](near/wasmer#71) it's a 10x speedup in singlepass backend compilation time. # Review - [ ] Add a short description of the change to the CHANGELOG.md file Co-authored-by: Bo Yao <[email protected]>
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.
LGTM, and thanks for upstreaming this! Let's hold off pulling this in until the next week -- we are going to branch the release soon, merging after release should give this change more time to bake in, and maybe even update the corresponding costs.
2681: fix singlepass slow compilation of many function wasm by using dynasm VecAssembler r=ptitSeb a=ailisp <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> We found in certain benchmark (a wasm with 150_000 no-op functions), compilation is slowed down by dynasmrt's mmapand mprotect syscalls, however, those mmap isn't used in wasmer and can be replaced by simpler VecAssembler. In this [bench](#71) it's a 10x speedup in singlepass backend compilation time. - [ ] Add a short description of the change to the CHANGELOG.md file Co-authored-by: Bo Yao <[email protected]>
I went ahead and manually cherry-picked in the change from upstream at 7945c3e, since its been approved and landed there. |
Compile was slow, especially for many function contracts because it use dynasm Assembler, which doing a few system call per wasm function. These system calls are about memory management (mmap, munmap, mprotect), but these are not used by wasmer at all (great finding by @matklad !). Drop them make compilation 10x faster:
Before ( 093eb59 ):
After: