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

Issue 720163002: Oilpan: Vector::reserveCapacity shouldn't reallocate backing storage always (Closed)

Created:
6 years, 1 month ago by haraken
Modified:
6 years, 1 month ago
CC:
blink-reviews, Mads Ager (chromium), oilpan-reviews, blink-reviews-wtf_chromium.org, aandrey+blink_chromium.org, kouhei+heap_chromium.org, Mikhail
Project:
blink
Visibility:
Public.

Description

Oilpan: 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 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+89 lines, -1 line) Patch
M Source/platform/heap/Heap.h View 3 chunks +5 lines, -0 lines 0 comments Download
M Source/platform/heap/Heap.cpp View 1 2 chunks +50 lines, -0 lines 0 comments Download
M Source/wtf/DefaultAllocator.h View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
M Source/wtf/Deque.h View 1 2 3 1 chunk +4 lines, -1 line 0 comments Download
M Source/wtf/Vector.h View 1 2 3 4 3 chunks +26 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (3 generated)
haraken
PTAL I think we can apply a similar optimization to PartitionAlloc. (However, we shouldn't do ...
6 years, 1 month ago (2014-11-13 11:02:08 UTC) #2
haraken
Erik: Would you take a look at this CL?
6 years, 1 month ago (2014-11-14 03:43:48 UTC) #3
tkent
lgtm https://codereview.chromium.org/720163002/diff/60001/Source/wtf/DefaultAllocator.h File Source/wtf/DefaultAllocator.h (right): https://codereview.chromium.org/720163002/diff/60001/Source/wtf/DefaultAllocator.h#newcode91 Source/wtf/DefaultAllocator.h:91: WTF_EXPORT static bool backingExpand(void*, size_t) Can we make ...
6 years, 1 month ago (2014-11-14 03:54:25 UTC) #5
haraken
Thanks for review! https://codereview.chromium.org/720163002/diff/60001/Source/wtf/DefaultAllocator.h File Source/wtf/DefaultAllocator.h (right): https://codereview.chromium.org/720163002/diff/60001/Source/wtf/DefaultAllocator.h#newcode91 Source/wtf/DefaultAllocator.h:91: WTF_EXPORT static bool backingExpand(void*, size_t) On ...
6 years, 1 month ago (2014-11-14 04:32:45 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/720163002/80001
6 years, 1 month ago (2014-11-14 04:33:39 UTC) #8
commit-bot: I haz the power
6 years, 1 month ago (2014-11-14 05:43:52 UTC) #9
Message was sent while issue was closed.
Committed patchset #5 (id:80001) as 185350

Powered by Google App Engine
This is Rietveld 408576698