New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 712714 link

Starred by 1 user

Issue metadata

Status: Archived
Owner:
Last visit > 30 days ago
Closed: May 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

reduce thread-hopping in WallpaperColorCalculator

Project Member Reported by est...@chromium.org, Apr 18 2017

Issue description

Every time we use WallpaperColorCalculator, we post a task to another thread. This is overkill for cases where color extraction will be very fast (e.g. a 1x1 wallpaper which is being used to create a solid color effect).

Hopefully the color extraction will become fast enough to just run on the UI thread. In the mean time, we should move color extraction operations on very small images onto the main thread.
 
What's the perf penalty for the thread hop? If it's small it might not be worth the code complexity.

Comment 2 by est...@chromium.org, Apr 18 2017

The code complexity is minimal. We'd only need to make sure the callers wouldn't choke on a synchronous return.

On some local runs the elapsed time with the thread hop is ~15ms and without is 0 (for the tiny image case). The delay varies with how busy the system is. It seems we run this at startup when the system is often very busy.
15 ms seems worth it. Thanks for measuring.

Labels: Proj-MaterialDesign-CrOS
Status: Started (was: Assigned)
CL: https://codereview.chromium.org/2824883006/
Project Member

Comment 5 by bugdroid1@chromium.org, Apr 25 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8

commit e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8
Author: bruthig <bruthig@chromium.org>
Date: Tue Apr 25 19:27:47 2017

[ash-md] Reduce thread hopping for cheap wallpaper color extraction.

Recent optimizations to the color_analysis::CalculateProminentColorOfBitmap()
has made it more expensive to perform color extraction asynchronously in some
cases. This change uses a simple image size heuristic to decide whether to
extract colors synchronously or asynchronously.

The optimizations made the 0-3 minute scale for the
'Ash.Wallpaper.TimeSpentExtractingColors' histogram overkill so it was replaced
with 'Ash.Wallpaper.ColorExtraction.Durations' one which uses a 0-10 second
scale.

This change also includes a new 'Ash.Wallpaper.ColorExtraction.UserDelay'
histogram that includes the thread switching delays incurred by asynchronous
calculations.

BUG=595010,  712714 
TEST=components_unittests --gtest_filter=*WallPaperColorCalculator*yncTest*

Review-Url: https://codereview.chromium.org/2824883006
Cr-Commit-Position: refs/heads/master@{#467075}

[modify] https://crrev.com/e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8/components/wallpaper/wallpaper_color_calculator.cc
[modify] https://crrev.com/e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8/components/wallpaper/wallpaper_color_calculator.h
[modify] https://crrev.com/e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8/components/wallpaper/wallpaper_color_calculator_unittest.cc
[modify] https://crrev.com/e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8/tools/metrics/histograms/histograms.xml

Project Member

Comment 6 by bugdroid1@chromium.org, Apr 25 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8

commit e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8
Author: bruthig <bruthig@chromium.org>
Date: Tue Apr 25 19:27:47 2017

[ash-md] Reduce thread hopping for cheap wallpaper color extraction.

Recent optimizations to the color_analysis::CalculateProminentColorOfBitmap()
has made it more expensive to perform color extraction asynchronously in some
cases. This change uses a simple image size heuristic to decide whether to
extract colors synchronously or asynchronously.

The optimizations made the 0-3 minute scale for the
'Ash.Wallpaper.TimeSpentExtractingColors' histogram overkill so it was replaced
with 'Ash.Wallpaper.ColorExtraction.Durations' one which uses a 0-10 second
scale.

This change also includes a new 'Ash.Wallpaper.ColorExtraction.UserDelay'
histogram that includes the thread switching delays incurred by asynchronous
calculations.

BUG=595010,  712714 
TEST=components_unittests --gtest_filter=*WallPaperColorCalculator*yncTest*

Review-Url: https://codereview.chromium.org/2824883006
Cr-Commit-Position: refs/heads/master@{#467075}

[modify] https://crrev.com/e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8/components/wallpaper/wallpaper_color_calculator.cc
[modify] https://crrev.com/e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8/components/wallpaper/wallpaper_color_calculator.h
[modify] https://crrev.com/e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8/components/wallpaper/wallpaper_color_calculator_unittest.cc
[modify] https://crrev.com/e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8/tools/metrics/histograms/histograms.xml

Labels: Merge-Request-59
Verified on veyron_minnie v 60.0.3084.0
Project Member

Comment 8 by sheriffbot@chromium.org, May 1 2017

Labels: -Merge-Request-59 Hotlist-Merge-Approved Merge-Approved-59
Your change meets the bar and is auto-approved for M59. Please go ahead and merge the CL to branch 3071 manually. Please contact milestone owner if you have questions.
Owners: amineer@(Android), cmasso@(iOS), gkihumba@(ChromeOS), Abdul Syed@(Desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 9 by bugdroid1@chromium.org, May 1 2017

Labels: -merge-approved-59 merge-merged-3071
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b04dec51600619369fb66ae642960d5df26bdbcd

commit b04dec51600619369fb66ae642960d5df26bdbcd
Author: Ben Ruthig <bruthig@chromium.org>
Date: Mon May 01 16:20:26 2017

[ash-md] Reduce thread hopping for cheap wallpaper color extraction.

Recent optimizations to the color_analysis::CalculateProminentColorOfBitmap()
has made it more expensive to perform color extraction asynchronously in some
cases. This change uses a simple image size heuristic to decide whether to
extract colors synchronously or asynchronously.

The optimizations made the 0-3 minute scale for the
'Ash.Wallpaper.TimeSpentExtractingColors' histogram overkill so it was replaced
with 'Ash.Wallpaper.ColorExtraction.Durations' one which uses a 0-10 second
scale.

This change also includes a new 'Ash.Wallpaper.ColorExtraction.UserDelay'
histogram that includes the thread switching delays incurred by asynchronous
calculations.

BUG=595010,  712714 
TEST=components_unittests --gtest_filter=*WallPaperColorCalculator*yncTest*

Review-Url: https://codereview.chromium.org/2824883006
Cr-Commit-Position: refs/heads/master@{#467075}
(cherry picked from commit e4135c8d12a6554d16e3bf16a8b79bb6462aa7d8)

Review-Url: https://codereview.chromium.org/2849163002 .
Cr-Commit-Position: refs/branch-heads/3071@{#324}
Cr-Branched-From: a106f0abbf69dad349d4aaf4bcc4f5d376dd2377-refs/heads/master@{#464641}

[modify] https://crrev.com/b04dec51600619369fb66ae642960d5df26bdbcd/components/wallpaper/wallpaper_color_calculator.cc
[modify] https://crrev.com/b04dec51600619369fb66ae642960d5df26bdbcd/components/wallpaper/wallpaper_color_calculator.h
[modify] https://crrev.com/b04dec51600619369fb66ae642960d5df26bdbcd/components/wallpaper/wallpaper_color_calculator_unittest.cc
[modify] https://crrev.com/b04dec51600619369fb66ae642960d5df26bdbcd/tools/metrics/histograms/histograms.xml

Status: Fixed (was: Started)
Labels: VerifyIn-61

Comment 12 by dchan@chromium.org, Jan 22 2018

Status: Archived (was: Fixed)

Sign in to add a comment