Skip to content

feat: MAP_SHARED client windows + occluded blit — BWM CPU 70% → 34% - #253

Merged
ryanbreen merged 1 commit into
mainfrom
feat/compositor-cpu-reduction
Mar 9, 2026
Merged

feat: MAP_SHARED client windows + occluded blit — BWM CPU 70% → 34%#253
ryanbreen merged 1 commit into
mainfrom
feat/compositor-cpu-reduction

Conversation

@ryanbreen

Copy link
Copy Markdown
Owner

Summary

  • MAP_SHARED client windows (op=21): Maps client window physical pages read-only into BWM's address space, eliminating the kernel page-by-page copy in read_window_buffer (op=14)
  • Lightweight dirty check (op=22): New check_window_dirty syscall compares generation counters without pixel copy
  • Occluded blit with span subtraction: Skips pixels covered by higher-z windows during blit, eliminating z-order repair entirely

Results (Parallels ARM64, 1920x1200, 4 windows)

MetricBeforeAfter
BWM CPU70%34%
FPS~100~130
Iteration time6451us4449us
Heap usage+8MB cachesZero extra
Visual qualityCorrectCorrect (no glitching)

Test plan

  • Zero build warnings (userspace + kernel)
  • Visual verification on Parallels — all 4 windows render correctly
  • No z-order glitching with overlapping windows
  • Performance verified via btop + bwm-perf serial output

🤖 Generated with Claude Code

Three optimizations that halve BWM's CPU usage while improving FPS:
1. MAP_SHARED client windows (op=21): Maps client window physical pages
read-only into BWM's address space, eliminating the kernel page-by-page
copy in read_window_buffer (op=14). Each window's backing pages are
mapped once at discovery time.
2. Lightweight dirty check (op=22): New check_window_dirty syscall compares
generation counters without any pixel copy. Replaces the full
read_window_buffer call for detecting changes.
3. Occluded blit with span subtraction: When blitting a dirty window, pixels
covered by higher-z windows are skipped using per-row span subtraction.
Eliminates z-order repair entirely (no re-blitting cached pixels for
overlapping windows).
Results on Parallels ARM64 (1920x1200, 4 windows):
- CPU: 70% → 34% (51% reduction)
- FPS: ~100 → ~130 (30% increase)
- Iteration time: 6451us → 4449us
- Heap savings: ~8MB (removed client_pixel_buf + per-window pixel_cache)
- Visual quality: No glitching — occluded blit handles z-order correctly
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ryanbreen
ryanbreen merged commit d5e50f3 into mainMar 9, 2026
1 of 4 checks passed
@ryanbreen
ryanbreen deleted the feat/compositor-cpu-reduction branch March 9, 2026 23:25
Sign up for freeto 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

@ryanbreen