RESOLVED FIXED 33896
FastAllocBase is probably making many of our objects a bit bigger
https://bugs.webkit.org/show_bug.cgi?id=33896
Summary FastAllocBase is probably making many of our objects a bit bigger
Zoltan Horvath
Reported 2010-01-20 05:45:48 PST
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.
Attachments
List of classes which first member is RefPtr and inherited from FastAllocBase (9.19 KB, text/plain)
2010-02-11 06:14 PST, Zoltan Horvath
no flags
List of classes which are instantiated by new and inherited from FastAllocBase (16.36 KB, text/plain)
2010-02-11 06:53 PST, Zoltan Horvath
no flags
List of classes whose size grows (1.70 KB, text/plain)
2010-03-31 01:02 PDT, Zoltan Horvath
no flags
Zoltan Horvath
Comment 1 2010-02-11 06:14:00 PST
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.
Zoltan Horvath
Comment 2 2010-02-11 06:53:36 PST
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.
Zoltan Horvath
Comment 3 2010-02-11 06:54:29 PST
I made these analysis on r54336.
Zoltan Horvath
Comment 4 2010-03-31 01:02:41 PDT
Created attachment 52139 [details] List of classes whose size grows I've put more effort on this topic, the results: The problem: 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; Solutions: 1. We can reorder the members (we can do this only a subset of the listed classes) e.g. struct ScopeNodeData (JavaScriptCore/parser/Nodes.h:1375) 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.
Darin Adler
Comment 5 2010-03-31 10:37:05 PDT
(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.
Zoltan Horvath
Comment 6 2010-04-07 03:43:46 PDT
(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.
Zoltan Horvath
Comment 7 2010-11-22 01:42:35 PST
The solution for the problem is to using macros instead of inheriting. See: bug #46589 and bug #42998.
Note You need to log in before you can comment on or make changes to this bug.