Skip to content

Add configurable pixmap caching with LRU eviction #114

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

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

Conversation

jserv
Copy link
Contributor

@jserv jserv commented Jul 30, 2025

This commit implements transparent pixmap caching to improve performance by reusing frequently allocated pixmaps with identical format and dimensions.

Cache features:

  • Automatic operation in twin_pixmap_create/destroy
  • LRU eviction policy respecting reference counts to prevent use-after-free
  • Hash-based lookup with collision handling via eviction

Configuration options (added to Features menu):

  • CONFIG_PIXMAP_CACHE: Enable/disable caching (default: y)
  • CONFIG_PIXMAP_CACHE_SIZE: Entry count 4-32 (default: 8)
  • CONFIG_PIXMAP_CACHE_MAX_KB: Memory limit 16-512KB (default: 64KB)

Summary by Bito

This pull request introduces a configurable pixmap caching feature to enhance performance by reusing frequently allocated pixmaps. It includes options for enabling caching, setting maximum cached entries, and defining memory limits, along with an LRU eviction policy to manage cache effectively and prevent memory issues.

This commit implements transparent pixmap caching to improve performance
by reusing frequently allocated pixmaps with identical format and
dimensions.

Cache features:
- Automatic operation in twin_pixmap_create/destroy
- LRU eviction policy respecting reference counts to prevent use-after-free
- Hash-based lookup with collision handling via eviction

Configuration options (added to Features menu):
- CONFIG_PIXMAP_CACHE: Enable/disable caching (default: y)
- CONFIG_PIXMAP_CACHE_SIZE: Entry count 4-32 (default: 8)
- CONFIG_PIXMAP_CACHE_MAX_KB: Memory limit 16-512KB (default: 64KB)
twin_coord_t height)
{
twin_coord_t stride = twin_bytes_per_pixel(format) * width;
if (stride % 4 != 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use IS_ALIGNED and ALIGN_UP

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