Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Issue 1252133002: Optimizing the time taken to build and show the WrenchMenu. (Closed)

Created:
5 years, 5 months ago by bruthig
Modified:
5 years, 3 months ago
Reviewers:
jonross, Peter Kasting
CC:
chromium-reviews, danakj, dcheng, jonross, tfarina
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Optimizing the time taken to build and show the WrenchMenu. While adding the ink drop ripple animation to the WrenchToolbarButton I found that the ToolbarView::ShowAppMenu(...) was taking a noticeable amount of time to build and show the menu. Patch set 1 has some profiling logging added and contains a log_output.txt showing that the majority of time is being spent calculating the string length for the ZoomView. Patch set 2 includes a fix to cache the max length and prevent it from being calculated more often than it needs to be. It also contains log_output.txt to show the time improvements. tldr for log_output.txt: With no functional changes patch set 1 spent 0.090804s creating the WrenchMenu and 0.248378s total time in Canvas::SizeStringFloat(...) over 64 invocations whereas Patch set 2 spent 0.003858s creating the WrenchMenu and 0.202926s total time in Canvas::SizeStringFloat(...) over 42 invocations. Note: The timings were harvested when running the ChromeOS build on a linux box so the values may be somewhat inflated however the percentage increase is still very dramatic. BUG=505587 Committed: https://crrev.com/bc8f9df013152ffc9708eb760fd4a0903cbad63d Cr-Commit-Position: refs/heads/master@{#340691}

Patch Set 1 : Profiling logging added. #

Patch Set 2 : Added lazy computation for the WrenchMenu::ZoomView::zoom_label_width_ and updated log_output.txt. #

Patch Set 3 : Removed experimental work, logging and output_log.txt. #

Total comments: 14

Patch Set 4 : Addressed pkasting@'s comments from patch set 3. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+48 lines, -33 lines) Patch
M chrome/browser/ui/views/toolbar/wrench_menu.cc View 1 2 3 8 chunks +48 lines, -33 lines 0 comments Download

Messages

Total messages: 19 (3 generated)
bruthig
5 years, 5 months ago (2015-07-23 18:37:38 UTC) #2
bruthig
pkasting@, can you PTAL?
5 years, 5 months ago (2015-07-23 18:38:18 UTC) #3
Peter Kasting
Cool. 0.2 sec in SizeStringFloat() still seems like a long time. Can we improve that ...
5 years, 5 months ago (2015-07-23 18:46:32 UTC) #4
jonross
A future optimization I believe can be gained when we change the layout of the ...
5 years, 5 months ago (2015-07-23 19:55:51 UTC) #6
jonross
https://codereview.chromium.org/1252133002/diff/40001/chrome/browser/ui/views/toolbar/wrench_menu.cc File chrome/browser/ui/views/toolbar/wrench_menu.cc (right): https://codereview.chromium.org/1252133002/diff/40001/chrome/browser/ui/views/toolbar/wrench_menu.cc#newcode663 chrome/browser/ui/views/toolbar/wrench_menu.cc:663: zoom_label_width_ = CalculateMaxWidthForZoomLabel(); On 2015/07/23 19:55:51, jonross wrote: > ...
5 years, 5 months ago (2015-07-23 20:01:16 UTC) #7
Peter Kasting
Also, I don't think patch set 3 is complete; I think there should be some ...
5 years, 5 months ago (2015-07-23 20:01:44 UTC) #8
bruthig
pkasting@, can you PTAL? Also it's not immediately obvious to me what changes are required ...
5 years, 5 months ago (2015-07-23 21:18:04 UTC) #9
bruthig
danakj@, do you have any idea if Canvas::SizeStringFloat(...) has been scrutinized for efficiency?
5 years, 5 months ago (2015-07-23 21:19:14 UTC) #10
danakj
On 2015/07/23 21:19:14, bruthig wrote: > danakj@, do you have any idea if Canvas::SizeStringFloat(...) has ...
5 years, 5 months ago (2015-07-23 21:43:31 UTC) #11
Peter Kasting
LGTM Ignore the .h comment, I was confused. Regarding inlining: separating code into different functions ...
5 years, 5 months ago (2015-07-23 21:49:36 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1252133002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1252133002/60001
5 years, 4 months ago (2015-07-28 14:31:25 UTC) #14
commit-bot: I haz the power
Committed patchset #4 (id:60001)
5 years, 4 months ago (2015-07-28 16:03:21 UTC) #15
commit-bot: I haz the power
Patchset 4 (id:??) landed as https://crrev.com/bc8f9df013152ffc9708eb760fd4a0903cbad63d Cr-Commit-Position: refs/heads/master@{#340691}
5 years, 4 months ago (2015-07-28 16:04:07 UTC) #16
Evan Stade
On 2015/07/23 19:55:51, jonross wrote: > A future optimization I believe can be gained when ...
5 years, 3 months ago (2015-09-18 18:56:50 UTC) #17
bruthig
> I don't think this is optimal because the string you display can change while ...
5 years, 3 months ago (2015-09-18 19:34:43 UTC) #18
Peter Kasting
5 years, 3 months ago (2015-09-18 19:37:24 UTC) #19
Message was sent while issue was closed.
On 2015/09/18 19:34:43, bruthig wrote:
> > I don't think this is optimal because the string you display can change
while
> > the menu is showing. But it seems like we should be able to just test what
we
> > assume to be the widest. 500%? Is the widest number going to depend on the
> > locale? I might start with setting the width based on 500% and test on a
> number
> > of locales to see if anything breaks. If so you could do the old trick of
> > creating a translateable string which is just a number of characters, and
> > defines the element's width, so translators can set a custom width for every
> > locale. 
> 
> Sounds like a good idea to me, if we really wanted to be safe we could add a
> unit test that verifies that the string length of the width string is actually
> larger than the string length of all the possible values.  Essentially we
would
> be paying the runtime expense during our tests instead of the end users.

Unittests aren't run in other locales, so that wouldn't save you from problems
there.

Powered by Google App Engine
This is Rietveld 408576698