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

Issue 34413002: Pickle::Write* micro-optimizations (Closed)

Created:
7 years, 2 months ago by piman
Modified:
7 years, 1 month ago
CC:
chromium-reviews, joi+watch-content_chromium.org, darin-cc_chromium.org, cc-bugs_chromium.org, erikwright+watch_chromium.org
Visibility:
Public.

Description

Pickle::Write* micro-optimizations Pickle is hot in some benchmarks. This helps by reworking WriteBytes in a few of ways: 1- Fold BeginWrite and EndWrite into WriteBytes since it's the only caller now. 2- keep track of the write offset, always aligned, separately, so that we can do alignment checks on the field sizes rather than the payload size (for next point). 3- provides a template version of WriteBytes with specializations for predefined sizes, that inline/optimize away alignment checks, padding, and memcpy. 4- change the meaning of capacity_ to not take the header size into account. This simplifies some arithmetic. BUG=307480 R=jar@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=231987

Patch Set 1 #

Total comments: 18

Patch Set 2 : rebase #

Total comments: 2

Patch Set 3 : Common WriteBytes definition #

Total comments: 9

Patch Set 4 : add overflow DCHECKs #

Total comments: 2

Patch Set 5 : Rebase on top of latest https://codereview.chromium.org/35893002/ , fold Resize-returns-void here #

Total comments: 2

Patch Set 6 : capacity_ -> capacity_after_header_ #

Patch Set 7 : Fix windows #

Unified diffs Side-by-side diffs Delta from patch set Stats (+91 lines, -91 lines) Patch
M base/pickle.h View 1 2 3 4 5 5 chunks +30 lines, -29 lines 0 comments Download
M base/pickle.cc View 1 2 3 4 5 6 7 chunks +58 lines, -59 lines 0 comments Download
M base/pickle_unittest.cc View 1 2 3 4 5 1 chunk +3 lines, -3 lines 0 comments Download

Messages

Total messages: 28 (0 generated)
piman
https://codereview.chromium.org/34413002/diff/1/base/pickle.cc File base/pickle.cc (left): https://codereview.chromium.org/34413002/diff/1/base/pickle.cc#oldcode314 base/pickle.cc:314: return NULL; behavior change: Resize can only fail when ...
7 years, 2 months ago (2013-10-22 06:05:58 UTC) #1
danakj
Cool :D I have some questions.. https://codereview.chromium.org/34413002/diff/1/base/pickle.cc File base/pickle.cc (right): https://codereview.chromium.org/34413002/diff/1/base/pickle.cc#newcode314 base/pickle.cc:314: Resize(std::max(capacity_ * 2, ...
7 years, 2 months ago (2013-10-22 17:22:05 UTC) #2
danakj
https://codereview.chromium.org/34413002/diff/1/base/pickle.cc File base/pickle.cc (right): https://codereview.chromium.org/34413002/diff/1/base/pickle.cc#newcode314 base/pickle.cc:314: Resize(std::max(capacity_ * 2, needed_size)); On 2013/10/22 17:22:05, danakj wrote: ...
7 years, 2 months ago (2013-10-22 17:23:15 UTC) #3
danakj
https://codereview.chromium.org/34413002/diff/1/base/pickle.cc File base/pickle.cc (right): https://codereview.chromium.org/34413002/diff/1/base/pickle.cc#newcode314 base/pickle.cc:314: Resize(std::max(capacity_ * 2, needed_size)); On 2013/10/22 17:23:16, danakj wrote: ...
7 years, 2 months ago (2013-10-22 18:23:54 UTC) #4
piman
Ready for review now, I rebased on top of https://codereview.chromium.org/35893002/ and https://codereview.chromium.org/38693003/ , and extracted ...
7 years, 2 months ago (2013-10-24 06:17:13 UTC) #5
piman
https://codereview.chromium.org/34413002/diff/140001/base/pickle.h File base/pickle.h (right): https://codereview.chromium.org/34413002/diff/140001/base/pickle.h#newcode219 base/pickle.h:219: return WritePOD(value); note: these actually always return true, so ...
7 years, 2 months ago (2013-10-24 06:24:00 UTC) #6
piman
https://codereview.chromium.org/34413002/diff/140001/base/pickle.cc File base/pickle.cc (right): https://codereview.chromium.org/34413002/diff/140001/base/pickle.cc#newcode273 base/pickle.cc:273: template <size_t length> void Pickle::WriteBytesStatic(const void* data) { BTW, ...
7 years, 2 months ago (2013-10-24 06:29:24 UTC) #7
jam
i'm not an owner here
7 years, 2 months ago (2013-10-24 16:17:59 UTC) #8
piman
Oops, -jam +jar
7 years, 2 months ago (2013-10-24 19:44:16 UTC) #9
piman
New version shares the code between WriteBytes and WriteBytesStatic. I verified that the same code ...
7 years, 2 months ago (2013-10-24 21:20:17 UTC) #10
jar (doing other things)
I'm curious... have you looked to see what optimizing compilers do to the pre-existing code? ...
7 years, 2 months ago (2013-10-24 22:36:48 UTC) #11
piman
Perf-wise, using the DelegatedFrame_ManyQuads_100000_100000 benchmark which is driving this (modeled from the limiting factor in ...
7 years, 2 months ago (2013-10-24 23:54:28 UTC) #12
piman
Assembly-wise, here's what I got. I don't have a windows machine at hand to dump ...
7 years, 2 months ago (2013-10-24 23:55:17 UTC) #13
piman
======================================== arm32 gcc ======================================== Before: 00000000 <_ZN6Pickle10WriteBytesEPKvi>: 0: b5f8 push {r3, r4, r5, r6, r7, ...
7 years, 2 months ago (2013-10-24 23:55:35 UTC) #14
piman
https://codereview.chromium.org/34413002/diff/230001/base/pickle.cc File base/pickle.cc (right): https://codereview.chromium.org/34413002/diff/230001/base/pickle.cc#newcode257 base/pickle.cc:257: DCHECK_LE(static_cast<size_t>(length), kuint32max); On 2013/10/24 22:36:48, jar wrote: > nit: ...
7 years, 1 month ago (2013-10-25 03:11:40 UTC) #15
Tom Sepez
https://codereview.chromium.org/34413002/diff/310001/base/pickle.h File base/pickle.h (right): https://codereview.chromium.org/34413002/diff/310001/base/pickle.h#newcode215 base/pickle.h:215: bool WriteBool(bool value) { drive-by: The follow-up to this ...
7 years, 1 month ago (2013-10-28 18:17:38 UTC) #16
Tom Sepez
https://codereview.chromium.org/34413002/diff/310001/base/pickle.h File base/pickle.h (right): https://codereview.chromium.org/34413002/diff/310001/base/pickle.h#newcode219 base/pickle.h:219: return WritePOD(value); drive-by: If I were trying to make ...
7 years, 1 month ago (2013-10-28 19:09:05 UTC) #17
piman
On Mon, Oct 28, 2013 at 11:17 AM, <tsepez@chromium.org> wrote: > > https://codereview.chromium.**org/34413002/diff/310001/base/**pickle.h<https://codereview.chromium.org/34413002/diff/310001/base/pickle.h> > File ...
7 years, 1 month ago (2013-10-28 19:27:01 UTC) #18
piman
On Mon, Oct 28, 2013 at 12:09 PM, <tsepez@chromium.org> wrote: > > https://codereview.chromium.**org/34413002/diff/310001/base/**pickle.h<https://codereview.chromium.org/34413002/diff/310001/base/pickle.h> > File ...
7 years, 1 month ago (2013-10-28 19:28:51 UTC) #19
piman
Rebased on top of Dana's latest version for https://codereview.chromium.org/35893002/ and I also folded Resize-returns-void here, ...
7 years, 1 month ago (2013-10-29 04:53:09 UTC) #20
jar (doing other things)
One thing to be careful here is: I've seen other suggestions for pickle changes recently. ...
7 years, 1 month ago (2013-10-29 16:50:48 UTC) #21
piman
https://codereview.chromium.org/34413002/diff/390001/base/pickle.h File base/pickle.h (right): https://codereview.chromium.org/34413002/diff/390001/base/pickle.h#newcode327 base/pickle.h:327: size_t capacity_; On 2013/10/29 16:50:48, jar wrote: > How ...
7 years, 1 month ago (2013-10-30 20:29:05 UTC) #22
jar (doing other things)
lgtm
7 years, 1 month ago (2013-10-31 02:23:36 UTC) #23
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/piman@chromium.org/34413002/560001
7 years, 1 month ago (2013-10-31 03:08:33 UTC) #24
commit-bot: I haz the power
Step "update" is always a major failure. Look at the try server FAQ for more ...
7 years, 1 month ago (2013-10-31 03:18:39 UTC) #25
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/piman@chromium.org/34413002/560001
7 years, 1 month ago (2013-10-31 03:26:38 UTC) #26
commit-bot: I haz the power
Step "update" is always a major failure. Look at the try server FAQ for more ...
7 years, 1 month ago (2013-10-31 03:47:24 UTC) #27
piman
7 years, 1 month ago (2013-10-31 04:03:25 UTC) #28
Message was sent while issue was closed.
Committed patchset #7 manually as r231987 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698