Skip to content

Use the trifecta div algorithm for 128-bit div on wasm #685

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

alexcrichton
Copy link
Member

This commit updates the #[cfg] annotations used to select the implementation of 128-bit division in compiler-builtins on wasm targets. This is done with relation to
https://github.com/WebAssembly/128-bit-arithmetic where performance of 128-bit operations is being investigated on WebAssembly. While I don't know much about the particulars of the two algorithms involved here the comments indicate that the "trifecta" variant is preferred if possible but it's not selected on 32-bit architectures. This rationale isn't as applicable to WebAssembly targets because despite the 32-bit pointer width there are often wider-than-pointer operations available as it's typically run on 64-bit machines.

Locally in testing a benchmark that performs division with a Rust-based bignum libraries whent from 350% slower-than-native to 220% slower-than-native with this change, a nice increase in speed. While this was tested with Wasmtime other runtimes are likely to see an improvement as well.

This commit updates the `#[cfg]` annotations used to select the
implementation of 128-bit division in compiler-builtins on wasm targets.
This is done with relation to
https://github.com/WebAssembly/128-bit-arithmetic where performance of
128-bit operations is being investigated on WebAssembly. While I don't
know much about the particulars of the two algorithms involved here the
comments indicate that the "trifecta" variant is preferred if possible
but it's not selected on 32-bit architectures. This rationale isn't as
applicable to WebAssembly targets because despite the 32-bit pointer
width there are often wider-than-pointer operations available as it's
typically run on 64-bit machines.

Locally in testing a benchmark that performs division with a Rust-based
bignum libraries whent from 350% slower-than-native to 220%
slower-than-native with this change, a nice increase in speed. While
this was tested with Wasmtime other runtimes are likely to see an
improvement as well.
@tgross35
Copy link
Contributor

tgross35 commented Sep 5, 2024

Makes sense, thanks!

@tgross35 tgross35 merged commit 1e5a686 into rust-lang:master Sep 5, 2024
24 checks passed
@tgross35
Copy link
Contributor

tgross35 commented Sep 5, 2024

Once #684 merges you can send a PR to rust-lang/rust updating to v0.1.125

@alexcrichton alexcrichton deleted the wams-div128 branch September 5, 2024 16:17
@alexcrichton
Copy link
Member Author

Happy to do so, and thanks!

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Sep 5, 2024
This commit updates the compiler-builtins crate from 0.1.123 to 0.1.125.
The changes in this update are:

* rust-lang/compiler-builtins#682
* rust-lang/compiler-builtins#678
* rust-lang/compiler-builtins#685
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Sep 11, 2024
…ins, r=tgross35

Update compiler-builtins to 0.1.125

This commit updates the compiler-builtins crate from 0.1.123 to 0.1.125. The changes in this update are:

* rust-lang/compiler-builtins#682
* rust-lang/compiler-builtins#678
* rust-lang/compiler-builtins#685

Fixes: rust-lang#129823
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 11, 2024
…s, r=<try>

Update compiler-builtins to 0.1.125

This commit updates the compiler-builtins crate from 0.1.123 to 0.1.125. The changes in this update are:

* rust-lang/compiler-builtins#682
* rust-lang/compiler-builtins#678
* rust-lang/compiler-builtins#685

try-job: aarch64-apple
try-job: aarch64-gnu
try-job: armhf-gnu
try-job: test-various
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 12, 2024
…ins, r=tgross35

Update compiler-builtins to 0.1.125

This commit updates the compiler-builtins crate from 0.1.123 to 0.1.125. The changes in this update are:

* rust-lang/compiler-builtins#682
* rust-lang/compiler-builtins#678
* rust-lang/compiler-builtins#685
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 12, 2024
…s, r=tgross35

Update compiler-builtins to 0.1.125

This commit updates the compiler-builtins crate from 0.1.123 to 0.1.125. The changes in this update are:

* rust-lang/compiler-builtins#682
* rust-lang/compiler-builtins#678
* rust-lang/compiler-builtins#685
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Sep 14, 2024
…ss35

Update compiler-builtins to 0.1.125

This commit updates the compiler-builtins crate from 0.1.123 to 0.1.125. The changes in this update are:

* rust-lang/compiler-builtins#682
* rust-lang/compiler-builtins#678
* rust-lang/compiler-builtins#685
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Sep 25, 2024
…ss35

Update compiler-builtins to 0.1.125

This commit updates the compiler-builtins crate from 0.1.123 to 0.1.125. The changes in this update are:

* rust-lang/compiler-builtins#682
* rust-lang/compiler-builtins#678
* rust-lang/compiler-builtins#685
shrirambalaji pushed a commit to shrirambalaji/rust that referenced this pull request Oct 6, 2024
This commit updates the compiler-builtins crate from 0.1.123 to 0.1.125.
The changes in this update are:

* rust-lang/compiler-builtins#682
* rust-lang/compiler-builtins#678
* rust-lang/compiler-builtins#685
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants