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

Change the function alignment of x86 to 32-bytes #8633

Merged
merged 2 commits into from
May 17, 2024

Conversation

hungryzzz
Copy link
Contributor

@hungryzzz hungryzzz commented May 16, 2024

The current default 16-bytes function alignment for x86-64 would cause suboptimal execution performance under some cases which are reported in #8573.

Based on the discussion "the CPU frontend grabs an aligned 32B or 64B chunk at a time" in #8573, this PR changes the default alignment from 16-bytes to 32-bytes for better performance.

Also rerun the cases reported in #8573 and the execution time will back to normal.

# After changescase ✗ wasmtime compile good.wasm -o good.cwasm
➜  case ✗ wasmtime compile bad.wasm -o bad.cwasm
➜  casetime wasmtime run --allow-precompiled good.cwasm
~/wasmtime/target/release/wasmtime run  good.cwasm  4.68s user 0.00s system 100% cpu 4.680 total
➜  casetime wasmtime run --allow-precompiled bad.cwasm
~/wasmtime/target/release/wasmtime run  bad.cwasm  4.67s user 0.01s system 99% cpu 4.681 total


# Before changescase ✗ wasmtime compile good.wasm -o good.cwasm
➜  case ✗ wasmtime compile bad.wasm -o bad.cwasm
➜  casetime wasmtime run --allow-precompiled good.cwasm
~/wasmtime/target/release/wasmtime run  good.cwasm  4.67s user 0.00s system 100% cpu 4.674 total
➜  casetime wasmtime run --allow-precompiled bad.cwasm
~/wasmtime/target/release/wasmtime run  bad.cwasm  9.36s user 0.01s system 100% cpu 9.365 total

@hungryzzz hungryzzz requested a review from a team as a code owner May 16, 2024 07:04
@hungryzzz hungryzzz requested review from elliottt and removed request for a team May 16, 2024 07:04
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen labels May 16, 2024
@alexcrichton
Copy link
Member

Thanks for this! It looks like this is causing changes in the disassembly of some existing tests. You can update the disassembly with WASMTIME_TEST_BLESS=1 cargo test --test disas locally and commit those changes to get pushed up here

@hungryzzz hungryzzz requested a review from a team as a code owner May 17, 2024 15:42
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Thanks!

@alexcrichton alexcrichton added this pull request to the merge queue May 17, 2024
Merged via the queue into bytecodealliance:main with commit 45a12a1 May 17, 2024
47 checks passed
@hungryzzz hungryzzz deleted the fix-8573 branch May 17, 2024 16:28
alexcrichton pushed a commit to alexcrichton/wasmtime that referenced this pull request May 20, 2024
* change the function alignment of x86 to 32-bytes

* Update disassembly tests

---------

Co-authored-by: ringz <[email protected]>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants