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

Issue 1249643007: Align base::Pickle allocations to 4k boundaries (Closed)

Created:
5 years, 5 months ago by Primiano Tucci (use gerrit)
Modified:
5 years, 5 months ago
Reviewers:
Lei Zhang, piman
CC:
chromium-reviews, tracing+reviews_chromium.org, wfh+watch_chromium.org, erikwright+watch_chromium.org, gavinp+memory_chromium.org, bashi
Base URL:
https://chromium.googlesource.com/chromium/src.git@accounting_fix
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Align base::Pickle allocations to 4k boundaries Currently the growth logic of base::Pickle (the one that kicks in exceeding the current capacity when writing) is as follows: new_payload_capacity = current_payload_capacity * 2 with an initial payload capacity of 64 bytes. However, the size of the heap held by Pickle (the one which gets realloc-ated on each growth) is: payload_capacity + header_size (typically 4-20 bytes). In practice, this means that when the Pickle is expanded, the size of its underlying heap becomes a power of two plus some extra. This causes funky behaviors of realloc, which makes extremely difficult to estimate the size of a pickle (for the sake of memory profiling, Pickle is used to store TracedValue(s)). This CL adds a small adjustment to the Pickle growth strategy, making the underlying realloc sizes close to a full page size. This in turn makes the realloc behavior much more predictable. As a bonus this CL refactors the use of "Align", moving it to base/bits.h BUG=512383 Committed: https://crrev.com/32a7f50559fbaf7319a32048383d4c790f2a3c20 Cr-Commit-Position: refs/heads/master@{#340318}

Patch Set 1 : #

Patch Set 2 : Relax for small pickles #

Total comments: 2

Patch Set 3 : COMPILE_ASSERT -> static_assert #

Total comments: 5

Patch Set 4 : Nits test #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+52 lines, -36 lines) Patch
M base/bits.h View 1 chunk +6 lines, -0 lines 0 comments Download
M base/bits_unittest.cc View 1 2 3 2 chunks +15 lines, -0 lines 1 comment Download
M base/memory/discardable_shared_memory.cc View 2 chunks +2 lines, -7 lines 0 comments Download
M base/pickle.h View 2 chunks +0 lines, -10 lines 0 comments Download
M base/pickle.cc View 1 2 9 chunks +17 lines, -8 lines 0 comments Download
M base/trace_event/trace_event_argument.cc View 1 2 3 2 chunks +8 lines, -2 lines 0 comments Download
M base/trace_event/trace_event_memory_overhead.cc View 1 2 3 2 chunks +4 lines, -9 lines 0 comments Download

Messages

Total messages: 17 (5 generated)
Primiano Tucci (use gerrit)
piman@ you seem to have done some micro-optimizations to Pickle. Could you please take a ...
5 years, 5 months ago (2015-07-23 21:00:45 UTC) #3
piman
On 2015/07/23 21:00:45, Primiano Tucci wrote: > piman@ you seem to have done some micro-optimizations ...
5 years, 5 months ago (2015-07-23 22:37:06 UTC) #4
piman
https://codereview.chromium.org/1249643007/diff/40001/base/pickle.cc File base/pickle.cc (right): https://codereview.chromium.org/1249643007/diff/40001/base/pickle.cc#newcode217 base/pickle.cc:217: pickle_kpayloadunit_must_be_a_power_of_two); nit: static_assert https://codereview.chromium.org/1249643007/diff/40001/base/pickle.cc#newcode379 base/pickle.cc:379: Resize(std::max(new_capacity, new_size)); You may ...
5 years, 5 months ago (2015-07-23 22:37:11 UTC) #5
Primiano Tucci (use gerrit)
> Well, the header itself doesn't grow, only the payload, right? Correct > Do we ...
5 years, 5 months ago (2015-07-23 23:00:50 UTC) #6
piman
OK, LGTM after nit.
5 years, 5 months ago (2015-07-23 23:10:36 UTC) #7
Primiano Tucci (use gerrit)
+thestig as base/ OWNER
5 years, 5 months ago (2015-07-23 23:24:02 UTC) #9
Lei Zhang
In the commit msg, there's a typo: "onw" https://codereview.chromium.org/1249643007/diff/60001/base/trace_event/trace_event_argument.cc File base/trace_event/trace_event_argument.cc (right): https://codereview.chromium.org/1249643007/diff/60001/base/trace_event/trace_event_argument.cc#newcode457 base/trace_event/trace_event_argument.cc:457: const ...
5 years, 5 months ago (2015-07-24 01:36:48 UTC) #10
Primiano Tucci (use gerrit)
See answers inline. I also added a test to bits_unittest.cc to cover the Align >In ...
5 years, 5 months ago (2015-07-24 09:37:38 UTC) #11
Lei Zhang
lgtm https://codereview.chromium.org/1249643007/diff/60001/base/trace_event/trace_event_argument.cc File base/trace_event/trace_event_argument.cc (right): https://codereview.chromium.org/1249643007/diff/60001/base/trace_event/trace_event_argument.cc#newcode457 base/trace_event/trace_event_argument.cc:457: const size_t kPickleAlignment = 4096; On 2015/07/24 09:37:38, ...
5 years, 5 months ago (2015-07-24 18:59:55 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1249643007/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1249643007/80001
5 years, 5 months ago (2015-07-24 19:00:19 UTC) #15
commit-bot: I haz the power
Committed patchset #4 (id:80001)
5 years, 5 months ago (2015-07-24 20:13:41 UTC) #16
commit-bot: I haz the power
5 years, 5 months ago (2015-07-24 20:14:23 UTC) #17
Message was sent while issue was closed.
Patchset 4 (id:??) landed as
https://crrev.com/32a7f50559fbaf7319a32048383d4c790f2a3c20
Cr-Commit-Position: refs/heads/master@{#340318}

Powered by Google App Engine
This is Rietveld 408576698