Last Comment Bug 846173 - Share more data between similar windows/compartments
: Share more data between similar windows/compartments
Status: NEW
[MemShrink:P2]
:
Product: Core
Classification: Components
Component: General (show other bugs)
: unspecified
: All All
: -- normal with 7 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
:
Mentors:
Depends on: Zones
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-27 21:08 PST by Nicholas Nethercote [:njn]
Modified: 2015-03-23 15:28 PDT (History)
19 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
about:memory for a fully-loaded TechCrunch (46.91 KB, text/plain)
2013-02-27 21:08 PST, Nicholas Nethercote [:njn]
no flags Details

Description Nicholas Nethercote [:njn] 2013-02-27 21:08:28 PST
Created attachment 719318 [details]
about:memory for a fully-loaded TechCrunch

techcrunch.com is an interesting site.  Each story on their front page has several buttons, for Facebook "Like", Google+ "+1", etc.  Except... the buttons are first loaded as just an image, and it's not until you hover the mouse over the image that the actual buttons manifest.

It's understandable why they do this -- the loaded buttons pull in a huge amount of code and data.  I've attached about:memory's output after loading all of these widgets -- there are almost 100 windows that get created.  That includes 30 variants (one per story) on each of these three:

  http://platform.twitter.com/widgets/tweet_button.html?...
  https://plusone.google.com/_/+1/fastbutton?...
  http://www.facebook.com/plugins/like.php?...

Most of which take 1--2 MiB on my 64-bit Linux build, and most of which look almost identical.

Here's what one of the plusone.google.com ones looks like.  The other two have
less JS, but the DOM/layout numbers are roughly similar.

> │  │  ├────2,097,488 B (00.71%) -- window(https://plusone.google.com/_/+1/fastbutton?bsv&size=medium&hl=en-US&origin=http%3A%2F%2Ftechcrunch.com&url=http%3A%2F%2Ftechcrunch.com%2F2013%2F02%2F27%2Flaw-would-force-patent-trolls-to-pay-for-failed-lawsuits-against-innovators%2F&gsrc=3p&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.AFEB0CwrTt8.O%2Fm%3D__features__%2Fam%3DqQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAItRSTPkayOPKWRaj7YBCgqYh_5rCQdUZg#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled&id=I7_1362026937573&parent=http%3A%2F%2Ftechcrunch.com&rpctoken=21016392)
> │  │  │    ├──1,638,872 B (00.55%) -- js/compartment(https://plusone.google.com/_/+1/fastbutton?bsv&size=medium&hl=en-US&origin=http%3A%2F%2Ftechcrunch.com&url=http%3A%2F%2Ftechcrunch.com%2F2013%2F02%2F27%2Flaw-would-force-patent-trolls-to-pay-for-failed-lawsuits-against-innovators%2F&gsrc=3p&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.AFEB0CwrTt8.O%2Fm%3D__features__%2Fam%3DqQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAItRSTPkayOPKWRaj7YBCgqYh_5rCQdUZg#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled&id=I7_1362026937573&parent=http%3A%2F%2Ftechcrunch.com&rpctoken=21016392)
> │  │  │    │  ├──1,056,768 B (00.36%) -- gc-heap
> │  │  │    │  │  ├────292,544 B (00.10%) -- objects
> │  │  │    │  │  │    ├──195,968 B (00.07%) ── function
> │  │  │    │  │  │    ├───77,248 B (00.03%) ── ordinary
> │  │  │    │  │  │    └───19,328 B (00.01%) ── dense-array
> │  │  │    │  │  ├────265,600 B (00.09%) ── unused-gc-things
> │  │  │    │  │  ├────211,584 B (00.07%) ── scripts
> │  │  │    │  │  ├────198,032 B (00.07%) -- shapes
> │  │  │    │  │  │    ├──104,960 B (00.04%) ── tree/global-parented
> │  │  │    │  │  │    ├───50,120 B (00.02%) ── dict
> │  │  │    │  │  │    └───42,952 B (00.01%) ── base
> │  │  │    │  │  ├─────62,440 B (00.02%) ── type-objects
> │  │  │    │  │  ├─────16,136 B (00.01%) ── arena-admin
> │  │  │    │  │  └─────10,432 B (00.00%) ── sundries
> │  │  │    │  ├────343,792 B (00.12%) -- type-inference
> │  │  │    │  │    ├──261,840 B (00.09%) ── type-scripts
> │  │  │    │  │    ├───65,536 B (00.02%) ── type-pool
> │  │  │    │  │    └───16,416 B (00.01%) ── allocation-site-tables
> │  │  │    │  ├────127,584 B (00.04%) -- shapes-extra
> │  │  │    │  │    ├───48,128 B (00.02%) ── compartment-tables
> │  │  │    │  │    ├───41,504 B (00.01%) ── tree-tables
> │  │  │    │  │    ├───25,312 B (00.01%) ── dict-tables
> │  │  │    │  │    └───12,640 B (00.00%) ── tree-shape-kids
> │  │  │    │  ├─────49,256 B (00.02%) ── script-data
> │  │  │    │  ├─────41,216 B (00.01%) ── objects-extra/slots
> │  │  │    │  └─────20,256 B (00.01%) ── other-sundries
> │  │  │    ├────255,424 B (00.09%) -- layout
> │  │  │    │    ├──182,768 B (00.06%) ── style-sets
> │  │  │    │    ├───43,904 B (00.01%) ── pres-shell
> │  │  │    │    ├────9,352 B (00.00%) ── frames/sundries
> │  │  │    │    ├────8,960 B (00.00%) ── style-contexts
> │  │  │    │    ├────6,984 B (00.00%) ── rule-nodes
> │  │  │    │    ├────2,368 B (00.00%) ── pres-contexts
> │  │  │    │    └────1,088 B (00.00%) ── line-boxes
> │  │  │    ├────165,552 B (00.06%) ── style-sheets
> │  │  │    └─────37,640 B (00.01%) -- dom
> │  │  │          ├──20,216 B (00.01%) ── text-nodes
> │  │  │          ├──10,032 B (00.00%) ── element-nodes
> │  │  │          ├───6,880 B (00.00%) ── other [2]
> │  │  │          └─────512 B (00.00%) ── event-targets [2]

Zones (bug 759585) will definitely help (e.g. "unused-gc-things" will plummet).  But even after it lands there will still be heaps of identical stuff in each window/compartment.  I can't help but wonder if we could share more stuff here.
Comment 1 Jeff D 2013-03-21 23:22:19 PDT
Conceptually, the hard problem seems to be identifying duplicate data. The ubiquity of these buttons makes me think there should be some kind of standard to advertise "hey this little snippet of code and the associated data might show up twenty places on about a million different websites, browsers should only keep one copy".

Since we don't have that kind of standard, we'll need to work through what heuristics to use. It's probably a good idea not to share across zones, for performance and possibly security. The domain name at least should match, but we can't rely on the entire rest of the name matching. If it's a possible match, compare content. If the near-match is confirmed, use copy-on-write for the twin compartments.

When it comes to that last step, techcrunch.com may be particularly tricky with its delayed loads. The first button to load has no duplicates, and therefore can do without copy-on-write: then its twin loads, and suddenly the compartment need to be copy-on-write.

Note You need to log in before you can comment on or make changes to this bug.