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

Cache results of font-config pattern search for reuse #121

Merged
merged 2 commits into from
Apr 28, 2022

Conversation

osialr
Copy link
Contributor

@osialr osialr commented Mar 22, 2022

This is a potential fix for #84. libfontmanager invokes the fontconfig matcher very often, especially on editor font-size. The implementation caches the results of the calls.

On my system, each call to match takes between 10-20 ms, with a few >100ms. Kubuntu + libreoffice exacerbates the problem, because it installs a lot of fonts and rules. But even on a minimal install of ubuntu, this should help because each call takes 1-10ms.

See IDEA-287246 for more debug diagnostics.

@osialr
Copy link
Contributor Author

osialr commented Apr 24, 2022

@avu I have signed the CLA.

You can change NUM_CACHED_VALUES to 0 to disable the caching mechanism to compare the performance. I choose the value of 8 empirically based on what smoothed out the UI sufficiently without frequent eviction.

I didn't try tuning the Pattern to FcFontMatch. Maybe there is an improved pattern that quickly retrieves the required values.

@avu
Copy link
Collaborator

avu commented Apr 26, 2022

@osialr thanks for signing. I've tested the patch - it greatly improves the performance. Nice work! Looking deeply into the implementation ...

@avu avu merged commit 23b6b18 into JetBrains:master Apr 28, 2022
@avu
Copy link
Collaborator

avu commented Apr 28, 2022

@osialr the changes look good, I've run commit testing and pushed them into JBR11 master

@osialr
Copy link
Contributor Author

osialr commented Apr 29, 2022

Great. I'm glad to help.

@avu
Copy link
Collaborator

avu commented Apr 29, 2022

@osialr thank you very much for your help!

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 this pull request may close these issues.

None yet

2 participants