Adding FastAllocBase as base class for objects has been making them all larger this is inflating WebKit’s memory use.
I'm going to collect the list of classes and try to measure the overhead.
Created attachment 48558 [details]
List of classes which first member is RefPtr and inherited from FastAllocBase
This list contains almost all classes (142) which are inherited from FastAllocBase and their first member is a RefPtr.
Created attachment 48560 [details]
List of classes which are instantiated by new and inherited from FastAllocBase
I did another analysis . This txt contains the list of classes - 956 pieces - which are instantiated by new and inherited from FastAllocBase somehow.
I made these analysis on r54336.
Created attachment 52139 [details]
List of classes whose size grows
I've put more effort on this topic, the results:
If a FastAllocBase class' first member is a FasAllocBase class then padding is added to the object and this making the object bigger.
The object's size grows by 4 bytes.
e.g. (on my Debian-x86)
FontPlatformDataCacheKey 28 bytes -> 32 bytes
Parser 76 bytes -> 80 bytes
MediaQueryExp 12 bytes -> 16 bytes
This problem stands for only in non-template cases, so aren't valid for the following cases:
- if the class is inherited from FastAllocBase through (e.g.) RefCounted<X>, padding are not added;
- if the first member is a template instantiation, padding are not added;
1. We can reorder the members (we can do this only a subset of the listed classes)
If we place int m_numConstants; to the first member of ScopeNodeData padding wont' be added.
2. Make FastAllocBase a class template and inherit from FastAllocBase<X>, so padding won't be added.
(In reply to comment #4)
> 2. Make FastAllocBase a class template and inherit from FastAllocBase<X>, so
> padding won't be added.
Lets do that.
(In reply to comment #5)
> (In reply to comment #4)
> > 2. Make FastAllocBase a class template and inherit from FastAllocBase<X>, so
> > padding won't be added.
> Lets do that.
I tested this solution on a simple instance and unfortunately it didn't work. Padding was added in template case as well.
The solution for the problem is to using macros instead of inheriting.
See: bug #46589 and bug #42998.