-
Notifications
You must be signed in to change notification settings - Fork 204
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
Faster float conversion operations #370
Conversation
I don't think so. |
cc @Amanieu @japaric @alexcrichton How would you like to proceed here? |
The original (Rust) implementations of anything in this crate were ported without any concern for performance on any platform. There was no effort in formally proving their correctness either. As thus I wouldn’t really hold any new changes to a significantly higher level of standard. So testing/benchmarking just on one or two different architectures would be good enough IME. |
I think it's possible to depend on an external crate but that crate will need to be modified to support Rust's build system. Have a look at how hashbrown does it. |
Then again compiler-builtins involves quite a bit of magic so you'll want to test this in a rustc build. |
compiler-builtins is special in that all crates except for libcore implicitly depend on it. |
I think it's a good idea to run benchmarks to verify that this performs as expected, but otherwise I agree that we don't need hugely rigorous testing. It'd be great to take this time to invest in the test suite to expand it from what it already is, but we should already at least lightly test these functions relative to the default implementation of compiler builtins. Unfortunately I don't think depending on a crate will work. The compiler-builtins crate is specially handled with respect to codegen and how it's linked, but that logic doesn't apply to the dependencies of compiler-builtins. If this can't be easily integrated into this crate, though, we could try making submodules work. |
I have greatly improved integer to float testing in |
Actually, since I am refactoring the floating point code right now, I think I will tackle this and try to implement any speedups from |
Now that I look deeply into it, it seems |
@AaronKutch Thanks :) I'll check if it passes all the new tests, and update the PR to integrate the implementations directly into this crate. |
Fuzzing can help discover interesting edge cases. The Rust Fuzz Book will get you started. You can use fuzzing to determine that your implementation matches the values produced by the current implementation with a simple Update: I've opened an initial PR for fuzzing: m-ou-se/floatconv#4 |
That LLVM based fuzzer is good for general structural fuzzing where it tries to hit all code paths. There is also a fuzzer in |
Closing in favour of #464 |
Hi!
I've been playing around a bit with int->float and float->int conversions lately. The implementations I have now seem to produce shorter assembly and perform faster than those currently in
compiler-builtins
. Some of them make a very significant difference. For example: u128->f64 is about 4 to 5 times faster on my x86_64 desktop, and u64->f64 runs about a factor 3 faster for the i686 target. Many others seem to provide roughly 30% improvement in my initial benchmarks, at least on the hardware I have here.For now I put them in this crate: https://docs.rs/floatconv/
I still want to optimize some more, do better benchmarks, and verify correctness better. But I figured it might be good to already ask some questions about potential integration into
compiler-builtins
: