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

Icon Pixbuf Cache #389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

helmo2019
Copy link

Adds a cache that keeps up to 50 icon pixbufs. This significantly speeds up modules such as hyprland-taskbar when there are windows with high-resolution icons (e.g. vscodium, which only has a 1024x1024 icon on my system) or a lot of icons to be drawn in general.

Fix

This PR introduces a simple cache for the icons' pixbufs. The parameters used to call create_pixbuf (icon_name, icon_size, icons_path) are put in a tuple and get mapped to the created pixbuf. If the cache size exceeds the set limit (currently 50), the oldest cache entries are removed until the cache size is within limits again.

Background

I noticed that opening certain applications would slow down the panel significantly (window and workspace changes took several seconds to become visible on the panel). After a bit of testing, I found out that the creation of some icon pixbufs (function create_pixbuf in tools.py) took significantly longer. For instance, while the icon pixbuf creation for firefox takes about 0.239ms on average, for vscodium it's 48.042ms on average (that's over 200 times more!). This results in noticeable lag and unresponsiveness when the panel is redrawn, which happens quite often.

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.

1 participant