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
Rename debugProfilePlatformChannels
to a constant that works in release mode
#134922
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
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.
Code looks good, needs renaming though.
@@ -25,6 +25,9 @@ KeyDataTransitMode? debugKeyEventSimulatorTransitModeOverride; | |||
/// The statistics include the total bytes transmitted and the average number of | |||
/// bytes per invocation in the last quantum. "Up" means in the direction of | |||
/// Flutter to the host platform, "down" is the host platform to flutter. | |||
/// | |||
/// Contrary to other debugging toggles in this package, this will function even | |||
/// when [kReleaseMode] is true. | |||
bool debugProfilePlatformChannels = false; |
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.
You'll have to remove the debug
prefix from the variable. Things with that prefix should be guaranteed to only run in debug builds.
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.
My interpretation of the "debug" prefix was that it's more of a debugging toggle - I couldn't find any other variables in any of the debug.dart
files in the framework that don't have the prefix. On the other hand, perhaps this is the first toggle that we want to be usable in release mode.
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.
It's my understanding that anything with the debug prefix should be tree-shaken in release builds. Maybe we'll have to move it out of the debug.dart
file in that case.
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.
Sure, I moved it to platform_channel.dart
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.
I'm a bit hesitant to accept this because this will have an effect on platform channel performance on release builds now. I'm not too excited about that, what do you think @dnfield ? I'd feel better if we ripped these out if we don't supply a flag. I know that that is a lot of work though since I've done that before.
Will it have any effect on performance when disabled? It is disabled by default so I'd only expect a small AOT size increase. (The |
Yep, every platform channel message will now be doing a boolean check against wether it was turned on or not. That wasn't the case previously because the treeshaker would remove that kRelease check since kRelease is a constant. I think ideally we want a way to turn this on so it will get built into an app on release and ripped out on release without some flag. |
In practice removing a boolean check is probably a micro-optimization and probably wouldn't have any effect on performance as a whole. I remember you mentioned that there were some benchmarks for platform channels though, can you point me to them to verify this? We can also make |
My take is that anything that happens at greater frequency than the frame rate we should do our best to make it as fast as possible. Boolean checks aren't as straightforward in dart as they are in other languages because of boxed types. There are these things called kernel transforms that allow people to change compiled code. Thats how we rip out asserts. I'd prefer |
Here is some build info we could use to turn on features like this:
Maybe there is already something like this you can already latch onto so you don't need to make a new option. Jacob would be a good person to ask. |
I made the toggle a const instead. I think in the near term, we shouldn't worry too much about usability concerns and having to patch this file to turn it on is an acceptable compromise. In the longer term, this should be something integrated into devtools and we can probably defer a proper way to turn it on at runtime for then. What do you think? |
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.
That sounds good to me. Thanks. Sorry, it isn't as straightforward to do this as I'd like.
auto label is removed for flutter/flutter/134922, due to - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.
|
/// The statistics include the total bytes transmitted and the average number of | ||
/// bytes per invocation in the last quantum. "Up" means in the direction of | ||
/// Flutter to the host platform, "down" is the host platform to flutter. | ||
const bool kProfilePlatformChannels = false; |
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.
Would it help to make this a const bool.fromEnvironment
?
I can't remember if that works well in google's build environment or not. It also may have issues on web.
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.
That could work and we could wire it up through the build rules to have something like:
flutter_application(
profilePlatformChannels = True,
)
But I'm not sure if this is so helpful in the near term. Since we probably don't want users to turn that flag on permanently, having to patch their flutter_application
is very similar to having to patch this file locally when profiling. For now I'm working on documentation to do things manually, but in the long term this can ideally be some toggle in devtools.
auto label is removed for flutter/flutter/134922, due to - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
I overwrote google testing because it seems like there's some infrastructure issue. I also checked that there are no other users of |
…rks in release mode (flutter/flutter#134922)
…rks in release mode (flutter/flutter#134922)
…rks in release mode (flutter/flutter#134922)
…rks in release mode (flutter/flutter#134922)
…rks in release mode (flutter/flutter#134922)
…rks in release mode (flutter/flutter#134922)
…rks in release mode (flutter/flutter#134922)
…rks in release mode (flutter/flutter#134922)
…rks in release mode (flutter/flutter#134922)
…rks in release mode (flutter/flutter#134922)
…rks in release mode (flutter/flutter#134922)
…rks in release mode (flutter/flutter#134922)
…4985) Manual roll Flutter from 893650416352 to f92884c7b846 (48 revisions) Manual roll requested by dit@google.com flutter/flutter@8936504...f92884c 2023-09-21 jiahaog@users.noreply.github.com Rename `debugProfilePlatformChannels` to a constant that works in release mode (flutter/flutter#134922) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com Mark ReastaurationManager not disposed (flutter/flutter#134832) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com cover more tests with leak tracing (flutter/flutter#134834) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com Fix leak in hardware_keyboard_test.dart (flutter/flutter#134380) 2023-09-20 sokolovskyi.konstantin@gmail.com Fix memory leak in _SelectableTextState (flutter/flutter#135049) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 39c0f2ea1f53 to 89d864552acd (4 revisions) (flutter/flutter#135169) 2023-09-20 ditman@gmail.com [deps] Update package:web dependency. (flutter/flutter#135174) 2023-09-20 yjbanov@google.com finer grained logging of Chromium launch sequence (flutter/flutter#135078) 2023-09-20 34871572+gmackall@users.noreply.github.com Upgrade AGP version in tracing_tests (flutter/flutter#134671) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com Cover cupertino/form_section_test with leak tracing (flutter/flutter#135158) 2023-09-20 sokolovskyi.konstantin@gmail.com Cover more test/widgets tests with leak tracking #7 (flutter/flutter#134943) 2023-09-20 goderbauer@google.com Enable strict-inference (flutter/flutter#135043) 2023-09-20 sokolovskyi.konstantin@gmail.com Cover more test/widgets tests with leak tracking #10 (flutter/flutter#135143) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com cover more tests with leak tracing (flutter/flutter#134833) 2023-09-20 ychris@google.com codeisn extension safe iOS framework (flutter/flutter#134966) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6f256257b79f to 55314d08d792 (2 revisions) (flutter/flutter#135151) 2023-09-20 gspencergoog@users.noreply.github.com Remove 'must be non-null' and 'must not be null' comments in widgets library (flutter/flutter#134992) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5f82fc2f6f24 to 6f256257b79f (1 revision) (flutter/flutter#135147) 2023-09-20 43054281+camsim99@users.noreply.github.com [Android] Add Java/AGP/Gradle incompatibility warning to `flutter create` (flutter/flutter#131444) 2023-09-20 engine-flutter-autoroll@skia.org Roll Packages from d4e2454 to 51e74b9 (12 revisions) (flutter/flutter#135145) 2023-09-20 gspencergoog@users.noreply.github.com Remove 'must not be null' comments from various libraries. (flutter/flutter#134984) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6535421b30d3 to 5f82fc2f6f24 (2 revisions) (flutter/flutter#135142) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 67d4aaef3c7b to 6535421b30d3 (1 revision) (flutter/flutter#135139) 2023-09-20 sokolovskyi.konstantin@gmail.com Cover more test/widgets tests with leak tracking #8 (flutter/flutter#135045) 2023-09-20 sokolovskyi.konstantin@gmail.com Cover more test/widgets tests with leak tracking #9 (flutter/flutter#135054) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 83b4df415bf3 to 67d4aaef3c7b (1 revision) (flutter/flutter#135128) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from df4e6c079682 to 83b4df415bf3 (2 revisions) (flutter/flutter#135102) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9c6b2500282b to df4e6c079682 (1 revision) (flutter/flutter#135101) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 24f7ac38dfa2 to 9c6b2500282b (3 revisions) (flutter/flutter#135098) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 36379b62bec8 to 24f7ac38dfa2 (2 revisions) (flutter/flutter#135096) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 81b93fc4a2cc to 36379b62bec8 (2 revisions) (flutter/flutter#135095) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5a924a9017d7 to 81b93fc4a2cc (2 revisions) (flutter/flutter#135093) 2023-09-20 gspencergoog@users.noreply.github.com Remove 'must be non-null' and 'must not be null' comments from material. (flutter/flutter#134991) 2023-09-20 34871572+gmackall@users.noreply.github.com Unpin url launcher (remake) (flutter/flutter#134958) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from a7af55c56aa6 to 5a924a9017d7 (10 revisions) (flutter/flutter#135085) 2023-09-20 engine-flutter-autoroll@skia.org Manual roll Flutter Engine from a7af55c56aa6 to 0d7db40c27fd (7 revisions) (flutter/flutter#135079) 2023-09-20 gspencergoog@users.noreply.github.com Remove 'must not be null' comments from painting and rendering libraries. (flutter/flutter#134993) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com cover more tests with leak tracking (flutter/flutter#134837) 2023-09-20 xilaizhang@google.com [flutter roll] Revert "Native assets support for Linux" (flutter/flutter#135069) 2023-09-20 engine-flutter-autoroll@skia.org Manual roll Flutter Engine from 10c480310926 to a7af55c56aa6 (4 revisions) (flutter/flutter#135071) 2023-09-19 zanderso@users.noreply.github.com Retry Linux web tests 1 time on roll presubmit (flutter/flutter#135073) 2023-09-19 ditman@gmail.com [web] Encode AssetManifest.bin as JSON and use that on the web. (flutter/flutter#131382) 2023-09-19 polinach@google.com Specify suggested format in doc comment. (flutter/flutter#134887) 2023-09-19 engine-flutter-autoroll@skia.org Manual roll Flutter Engine from 28f14e6eec4f to 10c480310926 (6 revisions) (flutter/flutter#135066) ...
…ease mode (flutter#134922) When it comes to startup profiling, it is very helpful to look at platform channels. `debugProfilePlatformChannels` today only works in debug and profile mode. Unfortunately, using profile mode is less accurate for startup profiling, because of the service isolate introducing additional overhead. This PR allows this toggle to work in release mode. Note that there are two parts to `debugProfilePlatformChannels`: - Adding timeline events - Logging statistics about platform channels I also considered adding a separate toggle to limit the scope of this change to the former, but that seems like complexity that we might not need at this time. Towards flutter#102189
…rks in release mode (flutter/flutter#134922)
…lutter#4985) Manual roll Flutter from 893650416352 to f92884c7b846 (48 revisions) Manual roll requested by dit@google.com flutter/flutter@8936504...f92884c 2023-09-21 jiahaog@users.noreply.github.com Rename `debugProfilePlatformChannels` to a constant that works in release mode (flutter/flutter#134922) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com Mark ReastaurationManager not disposed (flutter/flutter#134832) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com cover more tests with leak tracing (flutter/flutter#134834) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com Fix leak in hardware_keyboard_test.dart (flutter/flutter#134380) 2023-09-20 sokolovskyi.konstantin@gmail.com Fix memory leak in _SelectableTextState (flutter/flutter#135049) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 39c0f2ea1f53 to 89d864552acd (4 revisions) (flutter/flutter#135169) 2023-09-20 ditman@gmail.com [deps] Update package:web dependency. (flutter/flutter#135174) 2023-09-20 yjbanov@google.com finer grained logging of Chromium launch sequence (flutter/flutter#135078) 2023-09-20 34871572+gmackall@users.noreply.github.com Upgrade AGP version in tracing_tests (flutter/flutter#134671) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com Cover cupertino/form_section_test with leak tracing (flutter/flutter#135158) 2023-09-20 sokolovskyi.konstantin@gmail.com Cover more test/widgets tests with leak tracking flutter#7 (flutter/flutter#134943) 2023-09-20 goderbauer@google.com Enable strict-inference (flutter/flutter#135043) 2023-09-20 sokolovskyi.konstantin@gmail.com Cover more test/widgets tests with leak tracking flutter#10 (flutter/flutter#135143) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com cover more tests with leak tracing (flutter/flutter#134833) 2023-09-20 ychris@google.com codeisn extension safe iOS framework (flutter/flutter#134966) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6f256257b79f to 55314d08d792 (2 revisions) (flutter/flutter#135151) 2023-09-20 gspencergoog@users.noreply.github.com Remove 'must be non-null' and 'must not be null' comments in widgets library (flutter/flutter#134992) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5f82fc2f6f24 to 6f256257b79f (1 revision) (flutter/flutter#135147) 2023-09-20 43054281+camsim99@users.noreply.github.com [Android] Add Java/AGP/Gradle incompatibility warning to `flutter create` (flutter/flutter#131444) 2023-09-20 engine-flutter-autoroll@skia.org Roll Packages from d4e2454 to 51e74b9 (12 revisions) (flutter/flutter#135145) 2023-09-20 gspencergoog@users.noreply.github.com Remove 'must not be null' comments from various libraries. (flutter/flutter#134984) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6535421b30d3 to 5f82fc2f6f24 (2 revisions) (flutter/flutter#135142) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 67d4aaef3c7b to 6535421b30d3 (1 revision) (flutter/flutter#135139) 2023-09-20 sokolovskyi.konstantin@gmail.com Cover more test/widgets tests with leak tracking flutter#8 (flutter/flutter#135045) 2023-09-20 sokolovskyi.konstantin@gmail.com Cover more test/widgets tests with leak tracking flutter#9 (flutter/flutter#135054) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 83b4df415bf3 to 67d4aaef3c7b (1 revision) (flutter/flutter#135128) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from df4e6c079682 to 83b4df415bf3 (2 revisions) (flutter/flutter#135102) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9c6b2500282b to df4e6c079682 (1 revision) (flutter/flutter#135101) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 24f7ac38dfa2 to 9c6b2500282b (3 revisions) (flutter/flutter#135098) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 36379b62bec8 to 24f7ac38dfa2 (2 revisions) (flutter/flutter#135096) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 81b93fc4a2cc to 36379b62bec8 (2 revisions) (flutter/flutter#135095) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5a924a9017d7 to 81b93fc4a2cc (2 revisions) (flutter/flutter#135093) 2023-09-20 gspencergoog@users.noreply.github.com Remove 'must be non-null' and 'must not be null' comments from material. (flutter/flutter#134991) 2023-09-20 34871572+gmackall@users.noreply.github.com Unpin url launcher (remake) (flutter/flutter#134958) 2023-09-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from a7af55c56aa6 to 5a924a9017d7 (10 revisions) (flutter/flutter#135085) 2023-09-20 engine-flutter-autoroll@skia.org Manual roll Flutter Engine from a7af55c56aa6 to 0d7db40c27fd (7 revisions) (flutter/flutter#135079) 2023-09-20 gspencergoog@users.noreply.github.com Remove 'must not be null' comments from painting and rendering libraries. (flutter/flutter#134993) 2023-09-20 82763757+NobodyForNothing@users.noreply.github.com cover more tests with leak tracking (flutter/flutter#134837) 2023-09-20 xilaizhang@google.com [flutter roll] Revert "Native assets support for Linux" (flutter/flutter#135069) 2023-09-20 engine-flutter-autoroll@skia.org Manual roll Flutter Engine from 10c480310926 to a7af55c56aa6 (4 revisions) (flutter/flutter#135071) 2023-09-19 zanderso@users.noreply.github.com Retry Linux web tests 1 time on roll presubmit (flutter/flutter#135073) 2023-09-19 ditman@gmail.com [web] Encode AssetManifest.bin as JSON and use that on the web. (flutter/flutter#131382) 2023-09-19 polinach@google.com Specify suggested format in doc comment. (flutter/flutter#134887) 2023-09-19 engine-flutter-autoroll@skia.org Manual roll Flutter Engine from 28f14e6eec4f to 10c480310926 (6 revisions) (flutter/flutter#135066) ...
When it comes to startup profiling, it is very helpful to look at platform channels.
debugProfilePlatformChannels
today only works in debug and profile mode. Unfortunately, using profile mode is less accurate for startup profiling, because of the service isolate introducing additional overhead.This PR allows this toggle to work in release mode. Note that there are two parts to
debugProfilePlatformChannels
:I also considered adding a separate toggle to limit the scope of this change to the former, but that seems like complexity that we might not need at this time.
Towards #102189
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.