Open Bug 1378506 Opened 7 years ago Updated 2 years ago

HTMLMediaElement is way too large

Categories

(Core :: Audio/Video: Playback, enhancement, P5)

enhancement

Tracking

()

People

(Reporter: ehsan.akhgari, Unassigned)

Details

Right now, HTMLAudioElement is 1384 bytes on 64-bit and 912 bytes on 32-bit and HTMLVideoElement is 1400 bytes on 64-bit and 920 bytes on 32-bit.  These are significant outliers among the DOM nodes appearing in HTML documents, everything else being well under 512 bytes.

See this spreadsheet for the full data: https://docs.google.com/a/mozilla.com/spreadsheets/d/1i6yWXsDz_LFvvG6uvy57HupkHwSfdEjlIZq25Jsh7os/edit?usp=sharing

Most of this cost is shared due to HTMLMediaElement.  It would be nice to bring this cost down to under or equal to 512 bytes so that these can also participate in the optimization I'm working on in bug 1377999.
It is unclear to me whether we need to care too much about the sizeof media elements. They are complicated elements and I doubt we can make then as small as 512 (since even HTMLInputElement is close to that).
Also, if the elements don't use the memory, then it would be probably used by some helper objects and doing the allocation for helper objects is expensive.

However, perhaps 1k would be doable?
(In reply to Olli Pettay [:smaug] from comment #1)
> It is unclear to me whether we need to care too much about the sizeof media
> elements. They are complicated elements and I doubt we can make then as
> small as 512 (since even HTMLInputElement is close to that).

To make it clear I was mostly suggesting looking at packing this struct better.  Skimming this I noticed quite a few bools for example that currently take up 8 bytes on 64-bits, an 8 byte uint16_t, etc.  I didn't do the math to see how much that total would amount to, it's quite possible that it would only buy us a few hundred bytes tops.

> Also, if the elements don't use the memory, then it would be probably used
> by some helper objects and doing the allocation for helper objects is
> expensive.

Yes that is certainly not worth the effort.

> However, perhaps 1k would be doable?

I don't think that's worth doing.  I think the value of putting these two nodes into their own arena is fairly low (and if we decided we wanted to do that we could still do it at their current size.)  The only value in reducing their size to 512 and below would be in not having to make a new arena for them.  (Again, highly speculative benefit.)

To summarize, I mostly filed this bug to let people know about the size of these elements if it's surprising, a WONTFIX can be a fair resolution also.
Component: Audio/Video → Audio/Video: Playback
It isn't worth looking into unless you can show that creating 100,000 of them doesn't cause other problems first.
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.