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

Add a size limit to font_matches_cache and empty it when it's reached #217

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

MoSal
Copy link
Contributor

@MoSal MoSal commented Jan 22, 2024

In FontSystem, font_matches_cache is an ever growing cache.

It can also be a fast growing one in stress tests like running this
in cosmic-term:

 mpv -speed 3 -vo tct <some_video>

So this commit adds a size limit to that cache, and simply empties
it when that limit is reached, which shouldn't be a common occurrence
in normal usage.

@MoSal
Copy link
Contributor Author

MoSal commented Jan 22, 2024

There is another source of leakage with that stress test when a software renderer is involved. That one should be fixed by iced-rs/iced#2210.

src/font/system.rs Outdated Show resolved Hide resolved
src/font/system.rs Outdated Show resolved Hide resolved
 In `FontSystem`, `font_matches_cache` is an ever growing cache.

 It can also be a fast growing one in stress tests like running this
 in `cosmic-term`:

     mpv -speed 3 -vo tct <some_video>

 So this commit adds a size limit to that cache, and clears the cache
 when that limit is reached, which shouldn't be a common occurrence in
 normal usage.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
@MoSal MoSal force-pushed the matches_cache_limit branch from 8544f00 to 7d2e8bb Compare January 24, 2024 02:36
 `Attrs` contains info like color and metadata which are not relevant
 to font matching.

 So, add a new struct `FontMatchAttrs` which only contains the relevant
 info, and use it as a key in `FontSystem`'s `font_matches_cache`.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
@jackpot51 jackpot51 merged commit e0ae465 into pop-os:main Jan 24, 2024
1 of 2 checks passed
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.

2 participants