|
|
DescriptionValueSerializer: Replace use of std::vector with a delegate-allocated buffer.
BUG=chromium:148757
Committed: https://crrev.com/94142ed8c91d2110bba85d4820bd098da3f76fea
Cr-Commit-Position: refs/heads/master@{#40943}
Patch Set 1 #Patch Set 2 : further cleanup #Patch Set 3 : test update #Patch Set 4 : free the released buffer in test #Patch Set 5 : fix free call #Patch Set 6 : correct comment #
Messages
Total messages: 40 (27 generated)
The CQ bit was checked by jbroman@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by jbroman@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Description was changed from ========== ValueSerialiezr: Replace use of std::vector with a delegate-allocated buffer. BUG=chromium:148757 ========== to ========== ValueSerializer: Replace use of std::vector with a delegate-allocated buffer. BUG=chromium:148757 ==========
The CQ bit was checked by jbroman@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux64_asan_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_asan_rel_ng/buil...) v8_linux_mips64el_compile_rel on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_mips64el_compile_r...) v8_mac_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_mac_rel_ng/builds/12320) v8_win64_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_win64_rel_ng/builds/17569)
The CQ bit was checked by jbroman@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by jbroman@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
jbroman@chromium.org changed reviewers: + cbruni@chromium.org
It turns out that Android malloc is rather slow for certain cases; Blink's PartitionAlloc is more consistent across platforms and tuned for typical needs. This provides hooks for realloc+free, and gathers the memory management code from various uses of vector to one place, ReserveRawBytes. A simple doubling-plus-constant growth strategy is used, and the raw buffer is ultimately released to the embedder (which is responsible for freeing it). Blink side: https://codereview.chromium.org/2494823002
lgtm
The CQ bit was checked by jbroman@chromium.org
The CQ bit was unchecked by jbroman@chromium.org
jbroman@chromium.org changed reviewers: + danno@chromium.org
+danno for include/OWNERS (jochen is travelling)
jbroman@chromium.org changed reviewers: + jochen@chromium.org
(or jochen for include/OWNERS)
dskiba@chromium.org changed reviewers: + dskiba@chromium.org
I wonder if we could write a custom allocator for PA, and use it in std::vector<>. I.e. signature of ReleaseBuffer() would change to std::vector<uint8_t, partition_allocator<uint8_t>>, and that would basically be it. We could go even further and introduce template <class T> using pa_vector = std::vector<T, partition_allocator<T>>; with that ReleaseBuffer() signature becomes just 'pa_vector<uint8_t> ReleaseBuffer()'. Writing allocator is easy if you want to just intercept allocate/deallocate, for example see unshimmed_allocator here: https://codereview.chromium.org/2440393002/patch/100001/110004
On 2016/11/11 at 17:21:23, dskiba wrote: > I wonder if we could write a custom allocator for PA, and use it in std::vector<>. I.e. signature of ReleaseBuffer() would change to std::vector<uint8_t, partition_allocator<uint8_t>>, and that would basically be it. > > We could go even further and introduce > > template <class T> > using pa_vector = std::vector<T, partition_allocator<T>>; > > with that ReleaseBuffer() signature becomes just 'pa_vector<uint8_t> ReleaseBuffer()'. > > Writing allocator is easy if you want to just intercept allocate/deallocate, for example see unshimmed_allocator here: https://codereview.chromium.org/2440393002/patch/100001/110004 This type would have to be shared between Blink and V8 (which makes it complicated to figure out where it would live, especially since the allocator implementation is not in V8), and it would either have to not rely on any local state, of an allocator object would have to be provided. I looked at this, but it seemed much more complicated than doing this, especially since the needs of ValueSerializer are narrower than the full range of uses for std::vector. Plus, it makes it easier to take advantage of PartitionAlloc being able to provide the actual size of allocations, and its ability to sometimes realloc in place.
Oh, and lest I forget: it also makes it easier to skip the zero-filling that std::vector loves to do even when it's unnecessary (and using vector::insert, as this did previously, is surprisingly slow, because it doesn't seem to compile down to memcpy when that would be the efficient thing to do).
On 2016/11/11 17:30:41, jbroman wrote: > Oh, and lest I forget: it also makes it easier to skip the zero-filling that > std::vector loves to do even when it's unnecessary (and using vector::insert, as > this did previously, is surprisingly slow, because it doesn't seem to compile > down to memcpy when that would be the efficient thing to do). I see. Thanks for the explanation!
lgtm
The CQ bit was checked by jbroman@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Committed patchset #6 (id:100001)
Message was sent while issue was closed.
LGTM
Message was sent while issue was closed.
Description was changed from ========== ValueSerializer: Replace use of std::vector with a delegate-allocated buffer. BUG=chromium:148757 ========== to ========== ValueSerializer: Replace use of std::vector with a delegate-allocated buffer. BUG=chromium:148757 Committed: https://crrev.com/94142ed8c91d2110bba85d4820bd098da3f76fea Cr-Commit-Position: refs/heads/master@{#40943} ==========
Message was sent while issue was closed.
Patchset 6 (id:??) landed as https://crrev.com/94142ed8c91d2110bba85d4820bd098da3f76fea Cr-Commit-Position: refs/heads/master@{#40943} |