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

colours: cache X11 pixel values #1444

Merged
merged 1 commit into from
Mar 4, 2023
Merged

Conversation

bi4k8
Copy link
Collaborator

@bi4k8 bi4k8 commented Mar 4, 2023

Fixes #1442.

Checklist

  • I have described the changes
  • I have linked to any relevant GitHub issues, if applicable
  • [n/a] Documentation in doc/ has been updated
  • All new code is licensed under GPLv3

Description

This adds an unordered_map keeping track of the X11 pixel values for X11 colors we've allocated. The original design allocated X11 colors at parsing time and represented colors with pixel values everywhere. Now that we represent colors in a backend-independent way, we allocate X11 colors when we set the color in the backend. This means that we reallocate colors every time we draw, which creates a leak of X resources that the server has to track. To avoid this, we can simply cache the X11 pixel values we create, fixing the observed performance regression and server-side memory growth.

I tested this under XWayland against the conkyrc from #1442, after modifying the update_interval from 1.0 to 0.01 in order to speed up the resource leak. I first reproduced the memory leak and then verified that it no longer occurs with this patch.

now that we allocate these as-needed when converting colours to the X11 representation, we need to avoid reallocating the same colour over and over; cache them so we only allocate each colour once
@netlify
Copy link

netlify bot commented Mar 4, 2023

Deploy Preview for conkyweb canceled.

Name Link
🔨 Latest commit c08a782
🔍 Latest deploy log https://app.netlify.com/sites/conkyweb/deploys/6403691a139bfb00089a41ec

@github-actions github-actions bot added the sources PR modifies project sources label Mar 4, 2023
@brndnmtthws brndnmtthws merged commit 8f0a21b into brndnmtthws:main Mar 4, 2023
@brndnmtthws brndnmtthws added the bug Bug report or bug fix PR label Mar 4, 2023
@bi4k8 bi4k8 deleted the x11-pixel-cache branch March 4, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report or bug fix PR sources PR modifies project sources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Regression - High CPU and memory usage, probably related to new Colour type
2 participants