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

Mark Hahnenberg
Reported 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).
Attachments
Patch (38.83 KB, patch)
2013-02-01 12:00 PST, Mark Hahnenberg
no flags
Patch (43.49 KB, patch)
2013-02-01 12:34 PST, Mark Hahnenberg
no flags
Patch (42.93 KB, patch)
2013-02-01 14:21 PST, Mark Hahnenberg
oliver: review+
perf results (19.08 KB, text/plain)
2013-02-01 14:56 PST, Mark Hahnenberg
no flags
Mark Hahnenberg
Comment 1 2013-02-01 12:00:36 PST
Early Warning System Bot
Comment 2 2013-02-01 12:06:38 PST
Mark Hahnenberg
Comment 3 2013-02-01 12:34:57 PST
Early Warning System Bot
Comment 4 2013-02-01 12:46:31 PST
Early Warning System Bot
Comment 5 2013-02-01 13:52:10 PST
EFL EWS Bot
Comment 6 2013-02-01 14:16:00 PST
Mark Hahnenberg
Comment 7 2013-02-01 14:21:20 PST
Mark Hahnenberg
Comment 8 2013-02-01 14:56:32 PST
Created attachment 186153 [details] perf results
Filip Pizlo
Comment 9 2013-02-01 15:03:08 PST
Comment on attachment 186136 [details] Patch r=me too
Mark Hahnenberg
Comment 10 2013-02-01 15:14:45 PST
Note You need to log in before you can comment on or make changes to this bug.