Closed Bug 1812649 Opened 2 years ago Closed 2 years ago

Consider to have a cache in SetFontInternal

Categories

(Core :: Graphics: Canvas2D, task)

task

Tracking

()

RESOLVED FIXED
112 Branch
Tracking Status
firefox112 --- fixed

People

(Reporter: smaug, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sp3-anyone])

Attachments

(1 file)

https://share.firefox.dev/3jbg8RZ from an "unminified react-stockcharts profile" by jrmuizel
SetFontInternal seems to call into stylo always. Could we try to avoid that by having some kind of cache, perhaps MruCache?

Whiteboard: [sp3-anyone]
Type: defect → task
See Also: → 1815396
Blocks: gfx-triage
Flags: needinfo?(jfkthame)

I tried a very naive prototype of this and it does seem to help stockcharts by about 5%, https://treeherder.mozilla.org/perfherder/compare?originalProject=try&newProject=try&newRevision=3606fd02989e42cf750aadbce97ae1d1056a96e6&framework=13&originalRevision=2c3badf1064fb834656d2370006a688721778f48&page=1&showOnlyImportant=1. Although I'm not convinced the assumptions I made for the cache are correct.

Hah - just saw your comment come in, while I'm also in the middle of experimenting with a patch here! I did a similar thing, but using mfbt/MruCache.h rather than a linear array.... I suspect that may be better if we allow the cache to have rather more entries (MruCache default is 31) rather than just a handful.

I'll post my patch if tryserver seems happy with it.

Flags: needinfo?(jfkthame)
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/76e73894c489 Add a simple MRU cache to SetFontInternal, to reduce stylo usage from canvas2d contexts. r=gfx-reviewers,lsalzman

(In reply to Noemi Erli[:noemi_erli] from comment #5)

Backed out changeset 76e73894c489 (Bug 1812649) for causing failures in test_canvas_font_setter.html CLOSED TREE

Oh, right - the cache here is a little too aggressive. I think a simple fix will be to include the restyle generation in the cache key, to avoid the risk of using stale entries.

Try run to double-check: https://treeherder.mozilla.org/jobs?repo=try&revision=ff3129316852f1af9c134e6f861cfcf6b758df27

Flags: needinfo?(jfkthame)
Attachment #9317679 - Attachment description: Bug 1812649 - Add a simple MRU cache to SetFontInternal, to reduce stylo usage from canvas2d contexts. r=#gfx-reviewers → Bug 1812649 - Add a simple MRU cache to SetFontInternal, to reduce stylo usage from canvas2d contexts. r=lsalzman,#gfx-reviewers
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f32fdf85ea83 Add a simple MRU cache to SetFontInternal, to reduce stylo usage from canvas2d contexts. r=gfx-reviewers,lsalzman
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
No longer blocks: gfx-triage
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: