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

Issue 1129353003: Devirtualize base::BindState to save ~1% of Chrome's binary size (~1MB) (Closed)

Created:
5 years, 7 months ago by tapted
Modified:
5 years, 7 months ago
Reviewers:
Nico
CC:
chromium-reviews, erikwright+watch_chromium.org, chrome-apps-syd-reviews_chromium.org, tzik, Mikhail
Base URL:
https://chromium.googlesource.com/chromium/src.git@20150507-SizesExplorations
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Devirtualize base::BindState to save 1% of Chrome's binary size (1MB) Every call to base::Bind results in a new class declaration. Since base::internal::BindState is a virtual class, this also results in a bespoke vtable being defined. And that's a lot of vtables. Like 1MB worth of vtables, or 1% of Chrome's binary size. However, this vtable's sole purpose is for RefCountedThreadSafe:: Release(). Release() _does_ need to know precisely how to delete the BindState, but it doesn't need a vtable to do it. All it needs is a function pointer. This CL de-virtualizes base::BindState and instead moves the vtable pointer (which is merely an array holding the destructor) to a function pointer that contains the destructor instead. Since BindState previously contained a pointer-to-vtable the net memory effect of having the function pointer instead should be offset. And of course a 1MB binary size drop also means reduced memory requirements for the shared text-segment pages. Locally produced numbers for ChromiumFramework on Mac: pre-strip: - before: 192,031kB - after: 185,800kB post-strip: - before: 101,353kB - after: 100,353kB BUG=486594 Committed: https://crrev.com/e7e804c7d491ea23cfbf5b57a9ec1f8fa78b44a7 Cr-Commit-Position: refs/heads/master@{#329818}

Patch Set 1 #

Patch Set 2 : Neaten it all up #

Patch Set 3 : inline less, nits #

Patch Set 4 : Smaller diff #

Patch Set 5 : This old trap #

Total comments: 1

Patch Set 6 : fix a test #

Total comments: 7

Patch Set 7 : Keep using scoped_refptr #

Patch Set 8 : Keep the DCHECK #

Unified diffs Side-by-side diffs Delta from patch set Stats (+59 lines, -10 lines) Patch
M base/bind_internal.h View 1 2 2 chunks +12 lines, -4 lines 0 comments Download
M base/callback_internal.h View 1 2 3 4 5 6 7 2 chunks +27 lines, -3 lines 0 comments Download
M base/callback_internal.cc View 1 2 3 4 5 6 7 2 chunks +10 lines, -1 line 0 comments Download
M base/callback_unittest.cc View 1 2 3 2 chunks +10 lines, -2 lines 0 comments Download

Messages

Total messages: 32 (16 generated)
tapted
Hi Nico, please take a look. I think this is worth doing. There's some additional ...
5 years, 7 months ago (2015-05-11 07:17:44 UTC) #15
tapted
https://codereview.chromium.org/1129353003/diff/360001/base/callback_internal.h File base/callback_internal.h (right): https://codereview.chromium.org/1129353003/diff/360001/base/callback_internal.h#newcode15 base/callback_internal.h:15: #include "base/memory/scoped_ptr.h" // TODO(tapted): Remove. ref_counted and scoped_ptr are ...
5 years, 7 months ago (2015-05-11 08:56:17 UTC) #16
tapted
Nico: ping?
5 years, 7 months ago (2015-05-12 21:39:55 UTC) #17
Nico
This is super super cool. Basically lgtm, but it'd be nice if we could keep ...
5 years, 7 months ago (2015-05-14 04:28:13 UTC) #18
tapted
(addressing the question first to make sure we're on the same page) https://codereview.chromium.org/1129353003/diff/360001/base/callback_internal.h File base/callback_internal.h ...
5 years, 7 months ago (2015-05-14 04:36:14 UTC) #19
tapted
On 2015/05/14 04:36:14, tapted wrote: > (addressing the question first to make sure we're on ...
5 years, 7 months ago (2015-05-14 04:38:23 UTC) #20
tapted
5 years, 7 months ago (2015-05-14 04:38:33 UTC) #21
tapted
https://codereview.chromium.org/1129353003/diff/360001/base/callback_internal.h File base/callback_internal.h (left): https://codereview.chromium.org/1129353003/diff/360001/base/callback_internal.h#oldcode69 base/callback_internal.h:69: scoped_refptr<BindStateBase> bind_state_; On 2015/05/14 04:28:13, Nico wrote: > Shouldn't ...
5 years, 7 months ago (2015-05-14 05:06:54 UTC) #22
tapted
https://codereview.chromium.org/1129353003/diff/360001/base/callback_internal.h File base/callback_internal.h (left): https://codereview.chromium.org/1129353003/diff/360001/base/callback_internal.h#oldcode69 base/callback_internal.h:69: scoped_refptr<BindStateBase> bind_state_; On 2015/05/14 05:06:54, tapted wrote: > On ...
5 years, 7 months ago (2015-05-14 05:19:59 UTC) #23
Nico
Looks great :-)
5 years, 7 months ago (2015-05-14 05:25:10 UTC) #24
tapted
so.. I *think* my numbers were a little off since the vtables contributed a disproportionate ...
5 years, 7 months ago (2015-05-14 07:17:21 UTC) #25
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1129353003/400001
5 years, 7 months ago (2015-05-14 07:17:39 UTC) #28
commit-bot: I haz the power
Committed patchset #8 (id:400001)
5 years, 7 months ago (2015-05-14 08:03:42 UTC) #29
commit-bot: I haz the power
Patchset 8 (id:??) landed as https://crrev.com/e7e804c7d491ea23cfbf5b57a9ec1f8fa78b44a7 Cr-Commit-Position: refs/heads/master@{#329818}
5 years, 7 months ago (2015-05-14 08:04:23 UTC) #30
tapted
I'll keep http://crbug.com/486594 updated with perf data. Summary so far is: Link to perf results: ...
5 years, 7 months ago (2015-05-14 10:04:39 UTC) #31
Nico
5 years, 7 months ago (2015-05-14 16:43:55 UTC) #32
Message was sent while issue was closed.
(The Linux perf bots report size before striping, there's a bug for that
somewhere. Don't know about android.)
On May 14, 2015 3:04 AM, <tapted@chromium.org> wrote:

> I'll keep http://crbug.com/486594 updated with perf data. Summary so far
> is:
>
> Link to perf results:
>  - https://chromeperf.appspot.com/group_report?bug_id=486594
>
> The 1MB on Mac matches with the local tests. Linux sees a 3.5MB
> improvement.
> Android has the best %improve with ~2.5MB (     3.1% on
> lib_libchromeshell.so which
> seems to be the thing the perf bots are interested in).
>
> Windows doesn't seem to change much - it might not even tickle the perf
> bots.
> Looks like a ~100kB improvement in chrome.dll
>
> https://codereview.chromium.org/1129353003/
>

To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698