-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Event.message
: accept String
or Function
to avoid String
interpolation.
#56454
Conversation
…rpolation. Since `Event` is a logging object, its construction should not allocate new `String` objects or perform `String` interpolation.
Thank you for your contribution! This project uses Gerrit for code reviews. Your pull request has automatically been converted into a code review at: https://dart-review.googlesource.com/c/sdk/+/380202 Please wait for a developer to review your code review at the above link; you can speed up the review if you sign into Gerrit and manually add a reviewer that has recently worked on the relevant code. See CONTRIBUTING.md to learn how to upload changes to Gerrit directly. Additional commits pushed to this PR will update both the PR and the corresponding Gerrit CL. After the review is complete on the CL, your reviewer will merge the CL (automatically closing this PR). |
https://dart-review.googlesource.com/c/sdk/+/380202 has been updated with the latest commits from this pull request. |
3 similar comments
https://dart-review.googlesource.com/c/sdk/+/380202 has been updated with the latest commits from this pull request. |
https://dart-review.googlesource.com/c/sdk/+/380202 has been updated with the latest commits from this pull request. |
https://dart-review.googlesource.com/c/sdk/+/380202 has been updated with the latest commits from this pull request. |
https://dart-review.googlesource.com/c/sdk/+/380202 has been updated with the latest commits from this pull request. |
1 similar comment
https://dart-review.googlesource.com/c/sdk/+/380202 has been updated with the latest commits from this pull request. |
Event.message
: accept String
of Function
to avoid String
interpolation.Event.message
: accept String
or Function
to avoid String
interpolation.
https://dart-review.googlesource.com/c/sdk/+/380202 has been updated with the latest commits from this pull request. |
FYI: this has a significant improvement on GC and CPU. |
Is this infrastructure even turned on by default? That's strange - I would think that this should just be turned off when running in a default configuration cc @stereotype441 |
It's always creating the "Event" object. It will be faster if turned off, BTW. |
This logging logic was never intended to execute as part of a normal run of the analyzer. I believe it only executes if either (a) assertions are enabled or (b) If I'm wrong about that, then that's a bug, and so rather than try to optimize the logging logic, I'd prefer to fix the bug so that the logging logic doesn't get executed when it shouldn't be. @gmpassos you say that this has a significant improvement on GC and CPU. I would be really interested to know the amount of improvement you measured, and what was the command you used to measure it. That would help me understand whether there's a bug here that needs to be addressed, and if so, the magnitude of it. Thanks! |
I have this branch, that is forked from tag 3.5.0: https://github.com/gmpassos/sdk/tree/optimize-analyzer Analyzing the "analysis_server" package (compared to Dart 3.5.0): "dart language-server": 28sec (heap limi 820M) "my branch": 19sec (heap limit 725M) VM Parameters: "--no-enable-asserts" Parameters: "--train-using /path/to/analysis_server --protocol analyzer" Note that IntelliJ uses the analyzer protocol. (Once I reach my development computer I will send more details). |
Note that the "Event" construction, in the way that it's being done (current main branch), will have many String interpolation and many calls to the "describe" method, that is complex and is also calling "replace". |
@stereotype441 @mraleph @kevmoo Here are some benchmarks:
Git repository: Working path: Branch Best result out of 5 consecutive attempts:
This patch only over tag
Best result out of 5 consecutive attempts:
|
I think your benchmark is wrong. You need to run analysis server built in the same way, e.g. do I have tried adding |
Yes, agreed. I just tried comparing five runs of 3.5.0 to five runs of (3.5.0 plus these changes), using both 3.5.0, with So, it looks like there's no significant difference in runtime with and without these changes. However, I'm still really glad we're looking into this, because it appears that there is a very significant difference in runtime between I'll do a little digging and see if I can figure anything out. |
@stereotype441 you should chat with @a-siva who is driving #53576 |
Thanks! I'll follow up with @a-siva |
Yes, you are right. However, the performance difference between AOT and JIT is significant—JIT is about 47% slower, or AOT is on average 32% faster. Given the importance of the analyzer for every Dart/Flutter developer, I strongly recommend switching the analyzer to an AOT command (or have an option for that) to take advantage of the already improved performance. (AOT also has a lower memory footprint compared to the Dart VM). When I run the analysis server using --observe to collect hot spots, it creates Event objects. It's unclear how to enable or disable this undocumented logging feature, and we might need an optional parameter to disable it. |
Agreed. It has been our intention to switch all the tools invoked by
My guess is that the reason this is happening is that when you're running using --observe, you have assertions enabled. Would you mind checking whether that is the case? |
@mraleph I was wondering, in this case, what makes JIT run significantly slower than AOT? |
@gmpassos hard to say without detailed profiling, but AOT by now has a bunch of optimizations which are not in the JIT (for various reasons):
I think some combination of the above is most likely responsible for the difference. It is likely possible to make JIT much faster - but we don't currently have bandwidth (nor motivation) to invest into this. |
I am going close this PR based on our current understanding that this is debug only logging code. |
@mraleph thanks for the response. Regarding JIT, perhaps one of these "features" could be selected for implementation, based on its overall impact on performance. What is clear to me is that there’s still a huge potential for improvement. Best regards. |
Since
Event
is a logging object, its construction should not allocate newString
objects or performString
interpolation.This also:
Helps GC and reduces heap limit while analyzing a project/directory.
Avoids calls to
describe
:sdk/pkg/_fe_analyzer_shared/lib/src/type_inference/shared_inference_log.dart
Line 37 in 4954a03