Bug 108659

Summary: Structure should have a StructureRareData field to save space
Product: WebKit Reporter: Mark Hahnenberg <mhahnenberg>
Component: JavaScriptCoreAssignee: Mark Hahnenberg <mhahnenberg>
Status: RESOLVED FIXED    
Severity: Normal CC: gyuyoung.kim, philn, rakuco, webkit-ews, webkit.review.bot, xan.lopez
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
oliver: review+
perf results none

Description Mark Hahnenberg 2013-02-01 10:43:46 PST
Many of the fields in Structure are used in a subset of all total Structures; however, all Structures must pay the memory cost of those fields, regardless of whether they use them or not. Since we can have potentially many Structures on a single page (e.g. bing.com creates ~1500 Structures), it would be profitable to refactor Structure so that not every Structure has to pay the memory costs for these infrequently used fields.

To accomplish this, we can create a new StructureRareData class to house these seldom used fields which we can allocate on demand whenever a Structure requires it. This StructureRareData can itself be a JSCell, and can do all the marking of the fields for the Structure. The StructureRareData field will be part of a union with m_previous to minimize overhead. We'll add a new field to JSTypeInfo to indicate that the Structure has a StructureRareData field. During transitions, a Structure will clone its previous Structure's StructureRareData if it has one. There could be some potential for optimizing this process, but the initial implementation will be dumb since we'd be paying these overhead costs for each Structure anyways.

Initially we'll only put two fields in the StructureRareData to avoid a memory regression. Over time we'll continue to move fields from Structure to StructureRareData. Optimistically, this could potentially reduce our Structure memory footprint by up to around 75%. It could also clear the way for removing destructors from Structures (and into StructureRareData).
Comment 1 Mark Hahnenberg 2013-02-01 12:00:36 PST
Created attachment 186097 [details]
Patch
Comment 2 Early Warning System Bot 2013-02-01 12:06:38 PST
Comment on attachment 186097 [details]
Patch

Attachment 186097 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/16293947
Comment 3 Mark Hahnenberg 2013-02-01 12:34:57 PST
Created attachment 186106 [details]
Patch
Comment 4 Early Warning System Bot 2013-02-01 12:46:31 PST
Comment on attachment 186106 [details]
Patch

Attachment 186106 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/16333034
Comment 5 Early Warning System Bot 2013-02-01 13:52:10 PST
Comment on attachment 186106 [details]
Patch

Attachment 186106 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/16337115
Comment 6 EFL EWS Bot 2013-02-01 14:16:00 PST
Comment on attachment 186106 [details]
Patch

Attachment 186106 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/16341089
Comment 7 Mark Hahnenberg 2013-02-01 14:21:20 PST
Created attachment 186136 [details]
Patch
Comment 8 Mark Hahnenberg 2013-02-01 14:56:32 PST
Created attachment 186153 [details]
perf results
Comment 9 Filip Pizlo 2013-02-01 15:03:08 PST
Comment on attachment 186136 [details]
Patch

r=me too
Comment 10 Mark Hahnenberg 2013-02-01 15:14:45 PST
Landed in http://trac.webkit.org/changeset/141651.