Bug 108659 - Structure should have a StructureRareData field to save space
Summary: Structure should have a StructureRareData field to save space
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Hahnenberg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-01 10:43 PST by Mark Hahnenberg
Modified: 2013-02-01 15:14 PST (History)
6 users (show)

See Also:


Attachments
Patch (38.83 KB, patch)
2013-02-01 12:00 PST, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (43.49 KB, patch)
2013-02-01 12:34 PST, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (42.93 KB, patch)
2013-02-01 14:21 PST, Mark Hahnenberg
oliver: review+
Details | Formatted Diff | Diff
perf results (19.08 KB, text/plain)
2013-02-01 14:56 PST, Mark Hahnenberg
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.