Closed Bug 2081567 Opened 1 month ago Closed 1 month ago

Replace std::deque with std::vector for DrawEventRecorderPrivate_ExternalSurfacesHolder and DrawEventRecorderPrivate::ExternalImagesHolder. The surface holder appears in BlobItemData, WebRenderFallbackData, WebRenderMaskData and BlobImageKeyData; every Dr

Categories

(Core :: Graphics, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: perf-ai-bot, Assigned: lsalzman)

References

(Blocks 1 open bug)

Details

(Keywords: perf-alert, Whiteboard: [foofrix:249b3f89-db14-4cb5-86b6-2a0cab98993d])

Attachments

(1 external file, 1 obsolete file)

Replace std::deque with std::vector for DrawEventRecorderPrivate_ExternalSurfacesHolder and DrawEventRecorderPrivate::ExternalImagesHolder. The surface holder appears in BlobItemData, WebRenderFallbackData, WebRenderMaskData and BlobImageKeyData; every DrawEventRecorderPrivate owns both a surface holder and an image holder. With libstdc++, constructing each empty deque allocates a map and an element block, whereas default-constructed vectors avoid these allocations. This removes two allocations and eventual frees per unused holder, or four of each per recorder, targeting frequent construction and destruction of image-free blob display items in Charts-observable-plot. libstdc++ implementation. TakeExternalSurfaces continues to transfer ownership by move assignment. Canvas cleanup now snapshots the atomic processedCount, finds the first unprocessed entry, and erases the processed prefix. Entries completed after the snapshot may remain until later cleanup or destruction. Removing k > 0 entries with r entries remaining costs O(k+r), compared with O(k) for deque pop_front. Vector erasure retains capacity, and populated holders can incur additional growth or allocation churn after ownership transfers. The identified empty-construction allocation saving is specific to libstdc++; performance neutrality on other platforms or image-heavy workloads has not been established.

Problem

In Speedometer 3 Charts-observable-plot, each chart re-render builds new SVG subtrees, so blob display items (BlobItemData) are constantly created and destroyed. In the before profile (100 iterations of Charts-observable-plot, content main thread), 199 samples (about 1.0% of active samples) were spent constructing and destroying std::deque<DrawEventRecorderPrivate_ExternalSurfaceEntry>. 61 were constructions in BlobItemData::BlobItemData, via Grouper::ConstructGroups -> ConstructItemInsideInactive -> GetBlobItemDataForGroup. 138 were destructions in ~BlobItemData via ~WebRenderGroupData -> ~DIGroup: 87 of those came through nsIFrame::RemoveDisplayItemDataForDeletion during frame teardown, and 51 through nsSubDocumentFrame::Destroy -> PrepareInProcessPresShellsForDetach -> DestroyDisplayItemDataForFrames. The time was malloc/free of storage that was never used; 62 of the 138 destruction samples were jemalloc arena mutex lock/unlock. In the after profile, those deque frames are gone. Total samples dropped from 226 to 65 for ~BlobItemData, from 164 to 84 for BlobItemData::BlobItemData, and from 250 to 90 for ~DIGroup. Reported measurements: 8.763 -> 8.840 runs/min (+0.9%) for the job, and, in a separate session with 12 runs per side (6 alternating pairs of 2 runs), 8.258 -> 8.356 runs/min (+1.18%) for Charts-observable-plot. Tests reported: dom/canvas/test/test_canvas.html (3616 passed), WPT html/canvas/element/drawing-images-to-the-canvas and css/css-masking/mask-image (0 unexpected), layout/reftests/svg/image (41/41).

Performance

  • Benchmark: speedometer3
  • Test: sp3-full
  • Component: Graphics
  • Local Improvement: 0.87%

Validation

Blocks: speedometer3

Please move this bug to the correct component.

Once the Phabricator patch is ready for review, please commandeer it.

Flags: needinfo?(lsalzman)
Severity: -- → N/A
Type: defect → enhancement
Component: Performance: Automated Findings → Graphics
Flags: needinfo?(lsalzman)

Replace std::deque with std::vector for DrawEventRecorderPrivate_ExternalSurfacesHolder and DrawEventRecorderPrivate::ExternalImagesHolder. The surface holder appears in BlobItemData, WebRenderFallbackData, WebRenderMaskData and BlobImageKeyData; every Dr

Foofrix has found that deque incurs allocations in the default constructor even when it is not used,
whereas vector does not. So when the external image and surface queues are not used, it was incurring
unecessary allocations and deletions. It is overall a speedup to replace these queues with a vector.

Assignee: nobody → lsalzman
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #9659143 - Attachment is obsolete: true
Pushed by lsalzman@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/ceadd7be15c4 https://hg.mozilla.org/integration/autoland/rev/e51cabb7e4e6 Use vector instead of deque for external image and surface queues. r=gfx-reviewers,emilio,nical
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch

Perfherder has detected a browsertime performance change from push e51cabb7e4e6b884a100dddb4d596b535dc4d35b.

No action is required from the author; this comment is provided for informational purposes only.

Improvement Test Platform Options Absolute values [old vs new] Performance Profiles
1% speedometer3 Charts-observable-plot/total (doc) linux2404-64-shippable fission webrender 74.49 ms -> 73.68 ms Before/After

Need Help or Information?

If you have any questions, please reach out to fbilt@mozilla.com. Alternatively, you can find help on Slack by joining #perf-help, and on Matrix you can find help by joining #perftest.

Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.

Keywords: perf-alert
QA Whiteboard: [qa-triage-done-c161/b160]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: