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

Issue 439913002: Add a cache for FillFontFamilyMap. (Closed)

Created:
6 years, 4 months ago by erikchen
Modified:
6 years, 4 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Add a cache for FillFontFamilyMap. The function is called ~20,000 times on a fresh launch of Chrome on my MacBook Pro. Adding a dumb cache to reduce redundant fetches reduced cpu cycles in the function by 75% (profiled by DTrace). The class FontFamilyCache performs the caching, and the observation of the PrefService to ensure that the cache does not become stale. The Profile owns the FontFamilyCache to ensure that the cache does not outlive the PrefService. BUG=308095 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=287953

Patch Set 1 : #

Total comments: 6

Patch Set 2 : Comments from avi. #

Total comments: 7

Patch Set 3 : Comments from avi, round 2. #

Total comments: 15

Patch Set 4 : Comments from thestig. #

Total comments: 7

Patch Set 5 : Comments from thestig round 2. #

Total comments: 5

Patch Set 6 : Comments from thestig, round 3. #

Patch Set 7 : Rebase against top of tree. #

Patch Set 8 : Fix broken include. #

Patch Set 9 : Add profile destruction observer. #

Total comments: 4

Patch Set 10 : Add DCHECK as requested by thestig. #

Patch Set 11 : Minor unit test change. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+340 lines, -33 lines) Patch
M chrome/browser/chrome_content_browser_client.cc View 1 2 3 4 5 6 4 chunks +24 lines, -33 lines 0 comments Download
A chrome/browser/font_family_cache.h View 1 2 3 4 5 6 7 8 1 chunk +96 lines, -0 lines 0 comments Download
A chrome/browser/font_family_cache.cc View 1 2 3 4 5 6 7 8 9 1 chunk +134 lines, -0 lines 0 comments Download
A chrome/browser/font_family_cache_unittest.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +82 lines, -0 lines 0 comments Download
M chrome/chrome_browser.gypi View 1 2 3 4 5 6 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/chrome_tests_unit.gypi View 1 2 3 4 5 6 2 chunks +2 lines, -0 lines 0 comments Download

Messages

Total messages: 40 (0 generated)
erikchen
avi: Please review. (I know that you're not an OWNER of the relevant directories. If ...
6 years, 4 months ago (2014-08-05 00:57:20 UTC) #1
Avi (use Gerrit)
I'm not an expert on the subject matter but that part looks reasonable. Your method ...
6 years, 4 months ago (2014-08-05 01:50:26 UTC) #2
erikchen
avi: PTAL I switched over to base::SupportsUserData. I had noticed it before, but the comments ...
6 years, 4 months ago (2014-08-05 17:46:17 UTC) #3
erikchen
errr 1 sec, have to update some comments.
6 years, 4 months ago (2014-08-05 17:47:32 UTC) #4
erikchen
PTAL
6 years, 4 months ago (2014-08-05 17:49:25 UTC) #5
Avi (use Gerrit)
https://codereview.chromium.org/439913002/diff/40001/chrome/browser/chrome_content_browser_client.cc File chrome/browser/chrome_content_browser_client.cc (right): https://codereview.chromium.org/439913002/diff/40001/chrome/browser/chrome_content_browser_client.cc#newcode515 chrome/browser/chrome_content_browser_client.cc:515: profile->SetUserData(&chrome::kFontFamilyCacheKey, cache); And you set it on the BrowserContext, ...
6 years, 4 months ago (2014-08-05 18:07:37 UTC) #6
erikchen
avi: PTAL https://codereview.chromium.org/439913002/diff/40001/chrome/browser/font_family_cache.cc File chrome/browser/font_family_cache.cc (right): https://codereview.chromium.org/439913002/diff/40001/chrome/browser/font_family_cache.cc#newcode74 chrome/browser/font_family_cache.cc:74: size_t map_name_length = strlen(map_name); On 2014/08/05 18:07:36, ...
6 years, 4 months ago (2014-08-05 18:45:59 UTC) #7
Avi (use Gerrit)
The overall structure LGTM. I'm not that familiar with the font stuff and the like; ...
6 years, 4 months ago (2014-08-05 18:50:12 UTC) #8
erikchen
thestig: Looking for an OWNER review of chrome/browser/*
6 years, 4 months ago (2014-08-05 18:53:08 UTC) #9
Lei Zhang
https://codereview.chromium.org/439913002/diff/60001/chrome/browser/chrome_content_browser_client.cc File chrome/browser/chrome_content_browser_client.cc (right): https://codereview.chromium.org/439913002/diff/60001/chrome/browser/chrome_content_browser_client.cc#newcode506 chrome/browser/chrome_content_browser_client.cc:506: void FillFontFamilyMap(Profile* profile, How about making this a static ...
6 years, 4 months ago (2014-08-05 19:26:50 UTC) #10
erikchen
thestig: PTAL https://codereview.chromium.org/439913002/diff/60001/chrome/browser/chrome_content_browser_client.cc File chrome/browser/chrome_content_browser_client.cc (right): https://codereview.chromium.org/439913002/diff/60001/chrome/browser/chrome_content_browser_client.cc#newcode506 chrome/browser/chrome_content_browser_client.cc:506: void FillFontFamilyMap(Profile* profile, On 2014/08/05 19:26:49, Lei ...
6 years, 4 months ago (2014-08-05 20:49:23 UTC) #11
Lei Zhang
https://codereview.chromium.org/439913002/diff/60001/chrome/browser/font_family_cache.cc File chrome/browser/font_family_cache.cc (right): https://codereview.chromium.org/439913002/diff/60001/chrome/browser/font_family_cache.cc#newcode72 chrome/browser/font_family_cache.cc:72: for (FontFamilyMap::iterator it = font_family_map_.begin(); On 2014/08/05 20:49:23, erikchen ...
6 years, 4 months ago (2014-08-05 21:15:09 UTC) #12
erikchen
thestig: PTAL https://codereview.chromium.org/439913002/diff/60001/chrome/browser/font_family_cache.cc File chrome/browser/font_family_cache.cc (right): https://codereview.chromium.org/439913002/diff/60001/chrome/browser/font_family_cache.cc#newcode72 chrome/browser/font_family_cache.cc:72: for (FontFamilyMap::iterator it = font_family_map_.begin(); On 2014/08/05 ...
6 years, 4 months ago (2014-08-05 21:34:17 UTC) #13
Lei Zhang
https://codereview.chromium.org/439913002/diff/60001/chrome/browser/font_family_cache.cc File chrome/browser/font_family_cache.cc (right): https://codereview.chromium.org/439913002/diff/60001/chrome/browser/font_family_cache.cc#newcode72 chrome/browser/font_family_cache.cc:72: for (FontFamilyMap::iterator it = font_family_map_.begin(); On 2014/08/05 21:34:16, erikchen ...
6 years, 4 months ago (2014-08-05 21:48:56 UTC) #14
erikchen
thestig: PTAL https://codereview.chromium.org/439913002/diff/100001/chrome/browser/font_family_cache.cc File chrome/browser/font_family_cache.cc (right): https://codereview.chromium.org/439913002/diff/100001/chrome/browser/font_family_cache.cc#newcode94 chrome/browser/font_family_cache.cc:94: if (pref_name.compare(0, map_name_length, map_name) != 0) On ...
6 years, 4 months ago (2014-08-05 22:03:04 UTC) #15
Lei Zhang
lgtm https://codereview.chromium.org/439913002/diff/100001/chrome/chrome_tests_unit.gypi File chrome/chrome_tests_unit.gypi (right): https://codereview.chromium.org/439913002/diff/100001/chrome/chrome_tests_unit.gypi#newcode2586 chrome/chrome_tests_unit.gypi:2586: 'browser/font_family_cache_unittest.cc', On 2014/08/05 22:03:04, erikchen wrote: > On ...
6 years, 4 months ago (2014-08-05 22:11:14 UTC) #16
erikchen
The CQ bit was checked by erikchen@chromium.org
6 years, 4 months ago (2014-08-05 22:12:07 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/erikchen@chromium.org/439913002/140001
6 years, 4 months ago (2014-08-05 22:14:12 UTC) #18
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: linux_gpu on tryserver.chromium.gpu ...
6 years, 4 months ago (2014-08-05 23:10:05 UTC) #19
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 4 months ago (2014-08-05 23:12:39 UTC) #20
commit-bot: I haz the power
Try jobs failed on following builders: mac_gpu on tryserver.chromium.gpu (http://build.chromium.org/p/tryserver.chromium.gpu/builders/mac_gpu/builds/37744) ios_dbg_simulator on tryserver.chromium.mac (http://build.chromium.org/p/tryserver.chromium.mac/builders/ios_dbg_simulator/builds/2855) ios_rel_device ...
6 years, 4 months ago (2014-08-05 23:12:40 UTC) #21
erikchen
The CQ bit was checked by erikchen@chromium.org
6 years, 4 months ago (2014-08-06 00:12:22 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/erikchen@chromium.org/439913002/160001
6 years, 4 months ago (2014-08-06 00:13:34 UTC) #23
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: linux_gpu_triggered_tests on tryserver.chromium.gpu ...
6 years, 4 months ago (2014-08-06 06:15:25 UTC) #24
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 4 months ago (2014-08-06 06:22:43 UTC) #25
commit-bot: I haz the power
Try jobs failed on following builders: mac_chromium_compile_dbg on tryserver.chromium.mac (http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_compile_dbg/builds/3156)
6 years, 4 months ago (2014-08-06 06:22:43 UTC) #26
erikchen
The CQ bit was checked by erikchen@chromium.org
6 years, 4 months ago (2014-08-06 17:40:42 UTC) #27
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/erikchen@chromium.org/439913002/180001
6 years, 4 months ago (2014-08-06 17:41:59 UTC) #28
erikchen
The CQ bit was unchecked by erikchen@chromium.org
6 years, 4 months ago (2014-08-06 17:58:23 UTC) #29
erikchen
thestig: PTAL See the diff from patch set 9 against patch set 8. Profile destruction ...
6 years, 4 months ago (2014-08-06 20:15:16 UTC) #30
Lei Zhang
https://codereview.chromium.org/439913002/diff/240001/chrome/browser/font_family_cache.cc File chrome/browser/font_family_cache.cc (right): https://codereview.chromium.org/439913002/diff/240001/chrome/browser/font_family_cache.cc#newcode25 chrome/browser/font_family_cache.cc:25: chrome::NOTIFICATION_PROFILE_DESTROYED, We are trying to move away from Notifications. ...
6 years, 4 months ago (2014-08-06 20:56:55 UTC) #31
Avi (use Gerrit)
https://codereview.chromium.org/439913002/diff/240001/chrome/browser/font_family_cache.cc File chrome/browser/font_family_cache.cc (right): https://codereview.chromium.org/439913002/diff/240001/chrome/browser/font_family_cache.cc#newcode25 chrome/browser/font_family_cache.cc:25: chrome::NOTIFICATION_PROFILE_DESTROYED, On 2014/08/06 20:56:55, Lei Zhang wrote: > We ...
6 years, 4 months ago (2014-08-06 21:01:55 UTC) #32
Lei Zhang
lgtm++ then
6 years, 4 months ago (2014-08-06 21:03:30 UTC) #33
erikchen
https://codereview.chromium.org/439913002/diff/240001/chrome/browser/font_family_cache.cc File chrome/browser/font_family_cache.cc (right): https://codereview.chromium.org/439913002/diff/240001/chrome/browser/font_family_cache.cc#newcode132 chrome/browser/font_family_cache.cc:132: profile_pref_registrar_.RemoveAll(); On 2014/08/06 20:56:54, Lei Zhang wrote: > DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, ...
6 years, 4 months ago (2014-08-06 21:06:21 UTC) #34
erikchen
The CQ bit was checked by erikchen@chromium.org
6 years, 4 months ago (2014-08-06 21:07:57 UTC) #35
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/erikchen@chromium.org/439913002/260001
6 years, 4 months ago (2014-08-06 21:09:51 UTC) #36
erikchen
The CQ bit was checked by erikchen@chromium.org
6 years, 4 months ago (2014-08-06 23:27:32 UTC) #37
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/erikchen@chromium.org/439913002/280001
6 years, 4 months ago (2014-08-06 23:27:46 UTC) #38
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: mac_chromium_compile_dbg on tryserver.chromium.mac ...
6 years, 4 months ago (2014-08-07 03:02:54 UTC) #39
commit-bot: I haz the power
6 years, 4 months ago (2014-08-07 03:27:26 UTC) #40
Message was sent while issue was closed.
Change committed as 287953

Powered by Google App Engine
This is Rietveld 408576698