-
Notifications
You must be signed in to change notification settings - Fork 1.7k
double.remainder()
performance issues?
#55479
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
Comments
Similar results on (..checks...) intel CPU. An up to 40x slowdown suggests to me that the code is either using a very inefficient assembler instruction, or it's calling into the C runtime for each Or maybe remainder on I do think double remainder(num other) {
return _remainder(other.toDouble());
}
@pragma("vm:external-name", "Double_remainder")
external double _remainder(double other); which means calling a function in |
Yes, I was also thinking it could be some form of call overhead, it seems unlikely that disastrous assembler is produced across multiple platforms? I actually re-implemented
I think it's not a mathematical approximation, but an equivalence. I also considered that the two could be different numerically, but they seem to produce identical results over a pretty large number of inputs, i.e. |
//cc @alexmarkov @aam |
Hello everyone! Maybe I'm doing something wrong here, but I'm experiencing a pretty heavy performance hit with
double.remainder()
on ARM64 (M3) in Dart 3.3.3 on macOS.As per the documentation,
a.remainder(b)
is mathematically equivalent to:But when I compare the two, the custom implementation is somewhere between one and two orders of magnitude faster:
AOT (
dart compile exe
):JIT (
dart run
):Any ideas why this is the case?
The text was updated successfully, but these errors were encountered: