Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High resolution SDFs caused Firefox performance regression #10357

Closed
ChrisLoer opened this issue Feb 5, 2021 · 3 comments
Closed

High resolution SDFs caused Firefox performance regression #10357

ChrisLoer opened this issue Feb 5, 2021 · 3 comments
Assignees
Labels
performance ⚡ Speed, stability, CPU usage, memory usage, or power usage release blocker ⛔

Comments

@ChrisLoer
Copy link
Contributor

In testing for #10346, I realized that Firefox TinySDF performance went off some kind of cliff with the high-res SDF changes. Loading 15.4/35.675906/139.764176/-22.7 in a style with many CJK glyphs, time spent in TinySDF drawing code went from 116ms to 4759ms!

According to the profiler, it's all time spent in edt1d, although the glyphs look like they're being rendered at the same size as in Chrome/Safari, so I don't have any immediate ideas for why it would be so much slower.

cc @mourner @asheemmamoowala @ansis

@ChrisLoer ChrisLoer added the performance ⚡ Speed, stability, CPU usage, memory usage, or power usage label Feb 5, 2021
@ChrisLoer ChrisLoer self-assigned this Feb 5, 2021
@mourner
Copy link
Member

mourner commented Feb 5, 2021

That's so weird! Can you see if using the previous version and just doubling the resolution has a similar slow down, just to see if any other changes like metrics have to do with it? Profilers are weird and sometimes can show time spent incorrectly.

@ChrisLoer
Copy link
Contributor Author

You can disable the metrics logic by changing the true to a false in this line:

https://github.com/mapbox/tiny-sdf/blob/67de39bcc91d8be8e852d0b2b21134bccad6765c/index.js#L149

(Actually that still calls measureText but it only gets the "advance" and doesn't try to get the bounding boxes).

After making that change, Firefox performance goes back into the expected range. It wouldn't be very satisfying, but we could try to quickly patch this by disabling the metrics extraction on Firefox -- the "advance" is the only part we need for the new functionality, and the rest is just meant for performance optimization (not rasterizing glyphs any larger than they need to be).

@mourner
Copy link
Member

mourner commented Feb 8, 2021

Fixed by #10363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance ⚡ Speed, stability, CPU usage, memory usage, or power usage release blocker ⛔
Projects
None yet
Development

No branches or pull requests

3 participants