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

Issue 603153005: Sync: Improve Bookmark association time when running with 10K+ bookmarks. (Closed)

Created:
6 years, 2 months ago by stanisc
Modified:
6 years, 2 months ago
Reviewers:
Nicolas Zea
CC:
chromium-reviews, tim+watch_chromium.org, haitaol+watch_chromium.org, zea+watch_chromium.org, maniscalco+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Sync: Improve Bookmark association time when running with 10K+ bookmarks. I profiled Bookmark Sync association code on a Windows workstation with about 16K folders and bookmarks. This was for the scenario when bookmarks had been already synced and and BookmarkModelAssociator::BuildAssociations needed to match sync data to the already existing bookmark model. While it was fairly fast in absolute terms (less than 1 sec on my rather powerful workstation), I verified that 59% of samples for the UI thread were in BookmarkModelAssociator::BuildAssociations. The top 3 functions called from BuildAssociations and their costs in terms of UI thread sample counts are: browser_sync::BookmarkNodeFinder::FindBookmarkNode - 20.7% browser_sync::BookmarkChangeProcessor::UpdateBookmarkWithSyncData - 14.6% browser_sync::BookmarkNodeFinder::BookmarkNodeFinder - 13.9% Altogether BookmarkNodeFinder was responsible for almost 35% of all UI thread samples. Furthermore UTF16ToUTF8 function alone was responsible for 24% of UI thread samples. The reason UTF16ToUTF8 is so expensive is because it is used in custom comparator used with multiset which is a part of BookmarkNodeFinder implementation. Each bookmark node gets added and searched to BookmarkNodeFinder once. Altogether that results in approx 2*2*(N*logN/2) calls of UTF16ToUTF8 (and also N calls of UTF8ToUTF16). Each conversion involves an allocation. On a mobile platform the relative cost of this should be even higher because memory tends to be slower and CPU caches smaller. The fix replaces multiset with a hash_multimap where the key is the converted bookmark title. Therefore UTF16ToUTF8 ends up being called only once for each node and due to different lookup (by title vs. by node) UTF8ToUTF16 calls are eliminated. Also hashing should work more efficiently for long bookmark/folder titles than the binary search. Measurement showed that improved combined cost of BookmarkNodeFinder::BookmarkNodeFinder and BookmarkNodeFinder::FindBookmarkNode - close to 5x. And the overall cost of bookmark association - improved by 1.5-2x (when measured on my windows dev workstation). There is also an opportunity to optimize UpdateBookmarkWithSyncData which blindly applies data even when it guaranteed to be exactly the same, but I didn't touch it in this change. BUG=238621 Committed: https://crrev.com/2af5d96b379df6df01133e985051311adc581935 Cr-Commit-Position: refs/heads/master@{#297349}

Patch Set 1 : #

Total comments: 4

Patch Set 2 : Addressed CR feedback. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+42 lines, -50 lines) Patch
M chrome/browser/sync/glue/bookmark_model_associator.cc View 1 3 chunks +42 lines, -50 lines 0 comments Download

Messages

Total messages: 12 (5 generated)
stanisc
6 years, 2 months ago (2014-09-26 06:30:40 UTC) #5
Nicolas Zea
Mostly LG. You mentioned that there was an issue with your initial implementation that resulted ...
6 years, 2 months ago (2014-09-29 18:33:56 UTC) #6
stanisc
I've addressed the CR feedback. Regarding the issue with the title mismatch in the initial ...
6 years, 2 months ago (2014-09-29 22:34:22 UTC) #7
Nicolas Zea
LGTM, nice job!
6 years, 2 months ago (2014-09-29 22:36:00 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/603153005/80001
6 years, 2 months ago (2014-09-30 02:52:33 UTC) #10
commit-bot: I haz the power
Committed patchset #2 (id:80001) as 87135e1bc4166ff310a3d48add0ef01c0ed045a6
6 years, 2 months ago (2014-09-30 03:06:35 UTC) #11
commit-bot: I haz the power
6 years, 2 months ago (2014-09-30 03:07:27 UTC) #12
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/2af5d96b379df6df01133e985051311adc581935
Cr-Commit-Position: refs/heads/master@{#297349}

Powered by Google App Engine
This is Rietveld 408576698