Skip to content

Use a simpler implementation of Diagnosticable.toString when running in profile/release mode#28661

Merged
jason-simmons merged 1 commit intoflutter:masterfrom
jason-simmons:diagnostic_debug_label
Mar 4, 2019
Merged

Use a simpler implementation of Diagnosticable.toString when running in profile/release mode#28661
jason-simmons merged 1 commit intoflutter:masterfrom
jason-simmons:diagnostic_debug_label

Conversation

@jason-simmons
Copy link
Member

Diagnosticable.toString may be called in performance sensitive contexts
(for example, creating debug labels for Tickers)

…in profile/release mode

Diagnosticable.toString may be called in performance sensitive contexts
(for example, creating debug labels for Tickers)
@jason-simmons jason-simmons requested a review from Hixie February 28, 2019 19:43
@Hixie Hixie added the framework flutter/packages/flutter repository. See also f: labels. label Feb 28, 2019
@goderbauer
Copy link
Member

/cc @jacob314

Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we only use the simpler version in release mode. We don't really care about code size in profile mode and a user trying to get decent print statement debugging output in profile mode might appreciate the full toString.
That said, turning it off in profile mode is consistent with profile mode not supporting debugging so I'm fine either way.

Is there a code size difference in release mode with this change?
I would expect there is no code size difference in profile mode as profile mode still allows dumping the widget tree as a string last I checked.

@jason-simmons
Copy link
Member Author

The concern is related to speed, not size. Diagnosticable.toString is being called during construction of some UI elements such as Tickers. The goal is to avoid the performance cost of the full toString in cases where the string is unlikely to be used.

@jacob314
Copy link
Contributor

jacob314 commented Mar 2, 2019

If the toString is actually being called as part of rendering widgets then absolutely remove it from profile mode. Is there no way to remove the toString calls from ticker?

@jason-simmons
Copy link
Member Author

The toString call is used to construct a debug label for the Ticker. IIUC it's potentially useful to have a debug label even in profile/release mode as long as the cost is negligible.

@jason-simmons jason-simmons merged commit a1aea2e into flutter:master Mar 4, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants