DescriptionAlign 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
Messages
Total messages: 17 (5 generated)
|