DescriptionDevirtualize 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 #
Messages
Total messages: 32 (16 generated)
|