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

Issue 2807953002: Use base::flat_map for base::Value dictionary storage. (Closed)

Created:
3 years, 8 months ago by brettw
Modified:
3 years, 8 months ago
Reviewers:
jdoerrie
CC:
chromium-reviews, danakj+watch_chromium.org, vmpstr+watch_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Use base::flat_map for base::Value dictionary storage. This should give better memory locality and fewer allocations for our workloads. Most dictionaries are small and previously sorted (JSON Chrome writes like preferences is written in keyed-order). This makes the flat_map a better storage option because it avoids separate allocation for each node and has better memory locality. Performance from base_perftests JSONPerfTest.StressTest: Old: 84,807ms Just replacing the storage: 70,363ms Optimizing JSON parser: 69,286ms Primarily the improvement is in read performance (in creating the dictionary nodes) but write performance is also improved slightly, presumably due to better memory locality. I did some manual checking for the creation of large dictionary values (where this change may perform poorly) and did not find any in normal Chrome runs other than the JSON parser and the value copy constructor. Bringing flat_map.h into values_unittests.cc seems to confuse MSVC's ADL resolution of swap and it gives errors about calling flat_map::swap with base::Values. I wasn't able to figure out the source of this problem. The test is really checking for operator= that is generated by the default std::swap implementation (base::Value doesn't specialize a swap so the "using std/swap" pattern for ADL is a no-op), so I qualified the call to swap with a std::. Review-Url: https://codereview.chromium.org/2807953002 Cr-Commit-Position: refs/heads/master@{#463371} Committed: https://chromium.googlesource.com/chromium/src/+/8dd10d4011015ae6ce376a94666d56696e1ea7cd

Patch Set 1 #

Patch Set 2 : Swap #

Total comments: 4

Patch Set 3 : Fix swap #

Unified diffs Side-by-side diffs Delta from patch set Stats (+13 lines, -6 lines) Patch
M base/json/json_parser.cc View 3 chunks +4 lines, -3 lines 0 comments Download
M base/values.h View 1 2 3 chunks +4 lines, -1 line 0 comments Download
M base/values.cc View 1 2 1 chunk +4 lines, -0 lines 0 comments Download
M base/values_unittest.cc View 1 2 1 chunk +1 line, -2 lines 0 comments Download

Messages

Total messages: 30 (19 generated)
brettw
3 years, 8 months ago (2017-04-09 17:16:39 UTC) #3
jdoerrie
Those are great results, thanks a lot for doing this! https://codereview.chromium.org/2807953002/diff/20001/base/values.cc File base/values.cc (right): https://codereview.chromium.org/2807953002/diff/20001/base/values.cc#newcode162 ...
3 years, 8 months ago (2017-04-10 11:44:58 UTC) #13
brettw
Fix swap
3 years, 8 months ago (2017-04-10 17:43:23 UTC) #14
brettw
New snap up. I added a paragraph at the end of the CL description about ...
3 years, 8 months ago (2017-04-10 17:47:54 UTC) #17
brettw
Trying to make the map hold values instead of scoped_ptrs can be done independently of ...
3 years, 8 months ago (2017-04-10 17:50:32 UTC) #18
jdoerrie
On 2017/04/10 17:50:32, brettw (plz ping after 24h) wrote: > Trying to make the map ...
3 years, 8 months ago (2017-04-10 18:08:44 UTC) #21
brettw
On 2017/04/10 18:08:44, jdoerrie wrote: > On 2017/04/10 17:50:32, brettw (plz ping after 24h) wrote: ...
3 years, 8 months ago (2017-04-10 19:27:42 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2807953002/40001
3 years, 8 months ago (2017-04-10 19:28:52 UTC) #25
commit-bot: I haz the power
Committed patchset #3 (id:40001) as https://chromium.googlesource.com/chromium/src/+/8dd10d4011015ae6ce376a94666d56696e1ea7cd
3 years, 8 months ago (2017-04-10 19:52:01 UTC) #28
Mike West
A revert of this CL (patchset #3 id:40001) has been created in https://codereview.chromium.org/2811043002/ by mkwst@chromium.org. ...
3 years, 8 months ago (2017-04-11 06:47:23 UTC) #29
Mike West
3 years, 8 months ago (2017-04-11 06:52:22 UTC) #30
Message was sent while issue was closed.
On 2017/04/11 at 06:47:23, Mike West wrote:
> A revert of this CL (patchset #3 id:40001) has been created in
https://codereview.chromium.org/2811043002/ by mkwst@chromium.org.
> 
> The reason for reverting is: chromeos_unittests started failing in
https://uberchromegw.corp.google.com/i/chromium.chromiumos/builders/Linux%20C...;
FindIt points to this patch (with relatively low confidence), and the stack
trace at least looks plausible
(https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.chromiumos%2FLi....

Nevermind. https://bugs.chromium.org/p/chromium/issues/detail?id=710241
concludes that the tests were the problem, not this patch. I'll revert the
revert, and disable the tests..

Powered by Google App Engine
This is Rietveld 408576698