DescriptionOilpan: Vector::reserveCapacity shouldn't reallocate backing storage always
In the current implementation, when Vector::reserveCapacity expands its backing storage,
we always reallocate the backing storage (i.e., allocate a new storage -> memmove the storage
-> deallocate the old storage).
In this CL, we reallocate the backing storage only when necessary. If we can expand the tail
of the backing storage to the new capacity, we just expand the storage instead of reallocating
the storage.
This optimization works well for the following code:
HeapVector<X> vec;
for (...) {
X* x = new X(); // Note that X is allocated in a different heap than the collection backing heap.
vec.append(x); // If this calls Vector::reserveCapacity, we can expand the backing storage without reallocation.
}
but doesn't help the following code:
HeapVector<X> vec;
HeapVector<X> vec2;
for (...) {
X* x = new X();
X* x2 = new X();
vec.append(x); // If this calls Vector::reserveCapacity, we have to reallocate the storage.
vec2.append(x2); // If this calls Vector::reserveCapacity, we have to reallocate the storage.
}
This significantly improves a lot of benchmarks.
parser.query-selector-*: 20 - 50%
parser.html-parser: 5%
parser.xml-parser: 11%
shadow_dom.ShadowReprojection: 6%
...and many other benchmarks.
BUG=420515
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=185350
Patch Set 1 #Patch Set 2 : #Patch Set 3 : #Patch Set 4 : #
Total comments: 6
Patch Set 5 : #
Messages
Total messages: 9 (3 generated)
|