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

Hardcode Makie's default fonts to avoid findfont latency #2528

Closed
jkrumbiegel opened this issue Dec 27, 2022 · 5 comments · Fixed by #2531
Closed

Hardcode Makie's default fonts to avoid findfont latency #2528

jkrumbiegel opened this issue Dec 27, 2022 · 5 comments · Fixed by #2531

Comments

@jkrumbiegel
Copy link
Member

jkrumbiegel commented Dec 27, 2022

It seems that font search can account for long loading latency if a user has a lot of font files JuliaLang/julia#47184 (comment)

There were ideas to solve this on the FreeTypeAbstraction level by caching the list of fonts found on the system, for example in this issue: JuliaGraphics/FreeTypeAbstraction.jl#67

I think it might make sense to just add the names of Makie's default fonts as they are specified in the theme to Makie.to_font, so that findfont is not even run for those names. Sort of like:

if fontname == "TeX Gyre Heros Makie Regular"
   # access font file shipped with Makie
elseif fontname == "TeX Gyre Heros Makie Italic"
    ....
else
    findfont(...

I think this would be the easiest to do because it doesn't need a caching mechanism to alleviate the latency issue (we can still add better caching to FreeTypeAbstraction later if desired).

@timholy
Copy link
Contributor

timholy commented Dec 28, 2022

This seems like the right solution.

We're starting to write up TTFX blog posts etc. that will include many benchmarks, and it would be nice to be able to include Makie. Fixing this issue appears to be Makie's ticket-to-entry (I will exclude it from discussion otherwise), as on my system Makie's font selection accounts for almost all of the TTFP (compilation is just ~1%).

Plots has a similar (though much less serious) issue, xref jheinen/GR.jl#505.

@jkrumbiegel
Copy link
Member Author

@timholy do you want to check if the problem is gone with #2531?

@timholy
Copy link
Contributor

timholy commented Dec 28, 2022

Previously I had a latency for @time @eval display(plot(sin.(rand(100)))) of ~19s. Now it's 2s! Thanks so much!

@sefffal
Copy link

sefffal commented Dec 28, 2022

On my computer and Julia master, this brought down the using time of GLMakie from about 40s to 17.5s

@jkrumbiegel
Copy link
Member Author

It's crazy that this was going on for so long, goes to show again that the systems that the devs run matter a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants