-
Notifications
You must be signed in to change notification settings - Fork 81
Remove prefer-inline for non-trivial Matrix functions #347
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
Conversation
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.
Why? These were added deliberately, see discussions in the PR that added them.
Edit: I saw the other ping. It's OK as long as we benchmark and measure. See my PR descriptions.
(Btw, my PR description should've been the commit message as I asked here #345 (comment) so that anyone who looks at the changes in their editor can see why they were made)
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.
What's important is that the old methods that do type checks e.g. translate
, scale
... are inlined because often the type check code will then disappear and it will call the typed method.
What may be good (as mentioned in comments) to ensure if a public API functions delgates to another and passes constants, that those constants get folded away.
Apart from that, I agree that we don't have to force-inling the big implementation methods.
So generally lgtm
See what I did here. I think this is better @mkustermann |
On the VM at least things are about the same, if not a bit faster with the new bits. |
@@ -20,7 +20,7 @@ class Quad { | |||
/// The third point of the quad. | |||
Vector3 get point2 => _point2; | |||
|
|||
/// The third point of the quad. | |||
/// The fourth point of the quad. |
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.
Just a missed typing thing here...
lib/src/vector_math/matrix4.dart
Outdated
@pragma('vm:prefer-inline') | ||
@pragma('dart2js:prefer-inline') | ||
void translateByDouble(double tx, double ty, double tz, double tw) { | ||
void translateByDouble(double tx, double ty, double tz, [double tw = 1.0]) { |
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.
Optional parameters compliate calling conventions, the function now needs to check every time whether tw
was called or not. It's a good idea to avoid these in performance sensitive code, though I have no evidence that it matters in this particular case. We should benchmark and measure.
You can observe the difference by compiling to Wasm before and after and checking the code for this function. Make sure to call it with and without the optional parameter otherwise TFA will optimize it into a version that always takes tw
or never takes it.
Alternatively you can inline it always, in which case you get optimized code with no "is tw passed" checks, as in each call site you'll either pass it or not, and generate the code based on that.
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.
Should I drop em? Please give me code 😄
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.
Didn't I give you the code already in first round of review?
This usage of optional parameter isn't going to improve things - most likely the compiler will just make the call site implicitly pass 1.0
where before your changes this was done explicitly.
So it suffers from the same problem I outlined before, that even though a parameter is 1.0
constant, we don't inline, so we do unnecessary extra work.
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.
Happy to revert this change then.
I'm confusing about the private function then.
JIT mode doesn't matter AFAIK as we deploy in this mode. We care about AOT compiled, Wasm, and JS. |
We REALLY need a way to run benchmarks across all of our platforms easily... |
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
Revisions updated by `dart tools/rev_sdk_deps.dart`. dartdoc (https://github.com/dart-lang/dartdoc/compare/95f4208..e38f392): e38f3921 2025-05-16 Sigurd Meldgaard Remove analyzer_use_new_elements from analysis_options.yaml (dart-lang/dartdoc#4050) protobuf (https://github.com/dart-lang/protobuf/compare/9bd149b..b7753f6): b7753f6 2025-05-16 Devon Carew rev package:protobuf version (google/protobuf.dart#994) b5d20ff 2025-05-16 Ömer Sinan Ağacan Update protobuf changelog with `#981` (google/protobuf.dart#995) test (https://github.com/dart-lang/test/compare/55d1f9e..b9c59ea): b9c59ea0 2025-05-13 Liam Appelbe Set a debug name for test isolates (dart-lang/test#2494) a1e295b4 2025-05-13 Liam Appelbe Fix CI 3c3878af 2025-05-13 Liam Appelbe Include the test URI in the debug name 90e64ec2 2025-05-13 Nate Bosch Bump version d67c897b 2025-05-13 Liam Appelbe Merge branch 'master' into isolate_debug_name e6d4877e 2025-05-12 Jacob MacDonald release test packages (dart-lang/test#2495) 4097e1be 2025-05-07 Liam Appelbe revert workflow debugging 7800c010 2025-05-07 Liam Appelbe fmt 455483b5 2025-05-07 Liam Appelbe changelog c9b5b6fa 2025-05-07 Liam Appelbe fmt 39c4b31d 2025-05-07 Liam Appelbe Set a debug name for test isolates vector_math (https://github.com/google/vector_math.dart/compare/0279cb8..13f185f): 13f185f 2025-05-16 Kevin Moore Remove prefer-inline for non-trivial Matrix functions (google/vector_math.dart#347) webdev (https://github.com/dart-lang/webdev/compare/1ea8462..5dbb30e): 5dbb30eb 2025-05-12 Jessy Yameogo Support hot reload over websocket (dart-lang/webdev#2616) Change-Id: I85b001857d0864bd50390d82aa142938a4c530d4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428927 Commit-Queue: Devon Carew <[email protected]> Reviewed-by: Kevin Moore <[email protected]>
No description provided.