Closed Bug 1007897 Opened 11 years ago Closed 11 years ago

PDF.js spend 20-30% of time in SourceSurfaceCGBitmapContext::DrawTargetWillChange()

Categories

(Core :: Graphics: Layers, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: BenWa, Assigned: BenWa)

References

Details

(Whiteboard: [MemShrink][pdfjs-c-performance])

Attachments

(1 file)

Looks like we're accidentally holding a snapshot to the canvas.
mattwoodrow: BenWa: http://mxr.mozilla.org/mozilla-central/source/gfx/layers/CopyableCanvasLayer.cpp#92 mattwoodrow: should set mSurface to nullptr after that CopySurface call
With this patch it's down to 3%
Assignee: nobody → bgirard
Status: NEW → ASSIGNED
Attachment #8419683 - Flags: review+
Whiteboard: [MemShrink]
20--30% of what? I'm confused; the title sounds like this is a performance (speed) bug, but the patch looks like a MemShrink bug. Does freeing the memory also speed things up? Thanks.
There's a little more context on the Hacker News discussion that spawned this bug: https://news.ycombinator.com/item?id=7717191 "20% of the time is spent copying the canvas because someone is, likely erroneously, holding a reference to the canvas." It just sounded to me like it had to be a memory win, too. ;)
Sorry, I meant time. The problem is we hold a reference to an image longer then we need. When we go to touch the copy we see that someone is still referencing a snapshot of that image so we have to copy that image. The image will get deleted soon after but we still make a needless copy. This will reduce peak memory but wont really decrease average memory usage.
Summary: PDF.js spend 20-30% in SourceSurfaceCGBitmapContext::DrawTargetWillChange() → PDF.js spend 20-30% of time in SourceSurfaceCGBitmapContext::DrawTargetWillChange()
> This will reduce peak memory but wont really decrease average memory usage. Good! Given a choice, I prefer reducing peak than average.
Yeah, peak memory usage is a big problem on the phones, it can often spike quite high, and is hard to measure (and thus hard to fix).
Whiteboard: [MemShrink] → [MemShrink][pdfjs-c-performance]
Unsurprisingly: Improvement: Mozilla-Inbound - CanvasMark - MacOSX 10.6 (rev4) - 6.1% increase
Could the "<Regression> Mozilla-Inbound - CanvasMark - Android 2.2 (Native) - 9.12%" be from this?
It's hard to convince how releasing an image (and a snapshot flag) earlier could cause a regression. But it's the most likely in the regression window.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
Depends on: 1009646
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: