Optimize blur: per-window background caching#44
Merged
malbiruk merged 1 commit intomalbiruk:mainfrom Apr 19, 2026
Merged
Conversation
Replace global scene_generation tracking with per-window background fingerprinting. Blur now only recomputes when the background behind a specific window changes, not on any scene change. Key changes: - Add last_background_hash field to BlurCache - Implement hash_background_elements() to fingerprint elements behind window - Move behind_starts calculation before cache invalidation check - Replace scene_generation check with background hash comparison Impact: - GPU usage no longer scales with number of blurred windows - 6 blurred windows: ~30% GPU (was 90%+ before) - Static blurred window with static background: essentially free Fixes malbiruk#42
Owner
|
Thanks for working on this! I tested it on my laptop and on idle the per-window background caching optimization doesn't show a measurable improvement: 1 blurred terminal sits at ~2% GPU usage, and 6 blurred terminals at ~7% -- both with and without the change. I suspect the original 30% and 90% GPU from #42 might be NVIDIA-specific rather than a cache invalidation issue or something else I'm missing... Could you try reproducing the original issue on an unmodified main branch on your hardware? |
Owner
|
Active usage seems to improve a bit though, so I'll merge with follow-up commit consolidating the original needs_recompute block with the new one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #42 by implementing per-window background fingerprinting for blur cache invalidation.
Problem
Previously, blur cache was invalidated on any surface commit (via global
blur_scene_generation), causing blur to recompute even when the background behind a specific window hadn't changed. This led to:Solution
Replace global scene generation tracking with per-window background hash:
BlurCachenow storeslast_background_hashChanges
last_background_hashfield toBlurCachehash_background_elements()to fingerprint backgroundbehind_startscalculation before cache invalidation checkscene_generationcheck with background hash comparisonTest Results (NVIDIA GTX 1650)
Before:
After:
Key improvement: GPU usage no longer scales with number of blurred windows.
Notes