Closed Bug 1120271 Opened 10 years ago Closed 10 years ago

Add compacting support to SourceBuffer

Categories

(Core :: Graphics: ImageLib, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38
Tracking Status
firefox37 --- fixed
firefox38 --- fixed

People

(Reporter: seth, Assigned: seth)

References

Details

Attachments

(1 file, 1 obsolete file)

SourceBuffer uses memory efficiently when images have a Content-Length header, but when it doesn't know the size in advance it generally ends up allocating more memory than it needs because it grows its buffer exponentially. When an image has finished loading and all decoders have finished, we should compact the SourceBuffer so it uses only the memory it needs.
Timothy, don't feel like you need to review this today. It's ready now so I'm
going ahead and uploading it, though.

This patch adds compacting support for SourceBuffer. It's pretty
straightforward: we count the number of active consumers, and every time we
*both* have zero active consumers and the SourceBuffer is marked complete, we
attempt to compact. Compacting just means allocating a single new chunk that can
hold all of the data, and then copying all of the old chunks into it. We do this
with the lock held so that we don't have to worry about any new consumers coming
along and grabbing pointers to the data.
Attachment #8547282 - Flags: review?(tnikkel)
Attachment #8547282 - Flags: review?(tnikkel) → review+
Thanks for the review, Timothy!

This needed a minor rebase.
Attachment #8547282 - Attachment is obsolete: true
There are failures in that try job, but they're unexpected passes from bug 985193, which was mistakenly included in that try push.

I went ahead and pushed:

https://hg.mozilla.org/integration/mozilla-inbound/rev/3c89bb35ffd7
https://hg.mozilla.org/mozilla-central/rev/3c89bb35ffd7
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Comment on attachment 8549890 [details] [diff] [review]
Add compacting support for SourceBuffer

Approval Request Comment
[Feature/regressing bug #]: Part of fix for bug 1125272 and bug 1119938.
[User impact if declined]: Already approved.
[Describe test coverage new/current, TreeHerder]: In 38 for a long time.
[Risks and why]: Low risk; in 38 for a long time.
[String/UUID change made/needed]: None.
Attachment #8549890 - Flags: approval-mozilla-aurora?
Comment on attachment 8549890 [details] [diff] [review]
Add compacting support for SourceBuffer

Aurora approval previously granted for a collection of ImageLib related bugs that Seth worked on and QE verified before uplift.
Attachment #8549890 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Depends on: 1148684
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: