Skip to content

feat: event-driven compositor_wait syscall — BWM CPU 34% → 20%#254

Merged
ryanbreen merged 1 commit intomainfrom
feat/compositor-wait-syscall
Mar 10, 2026
Merged

feat: event-driven compositor_wait syscall — BWM CPU 34% → 20%#254
ryanbreen merged 1 commit intomainfrom
feat/compositor-wait-syscall

Conversation

@ryanbreen
Copy link
Owner

Summary

  • New compositor_wait syscall (op=23): Blocks BWM in the kernel until work arrives — dirty window, mouse movement, registry change, or timeout
  • USB HID mouse wake: Mouse movement wakes compositor immediately for low-latency input
  • Registry generation tracking: Window registration bumps atomic counter, wakes compositor
  • Removed duplicate blocking from op=16: compositor_wait now handles all blocking, op=16 returns immediately when nothing dirty

Results (Parallels ARM64, 1920x1200, 4 windows)

Metric Before (MAP_SHARED) After (compositor_wait)
BWM CPU 34% ~20%
Bounce FPS ~130 ~186
Idle wakes 50% 0%

Combined total improvement from baseline:

  • BWM CPU: 70% → ~20% (71% reduction)
  • Bounce FPS: ~100 → ~186 (86% increase)

Test plan

  • Zero build warnings (userspace + kernel)
  • Visual verification — all 4 windows render correctly
  • Bounce FPS improved (186 vs 130)
  • Event-driven wake pattern (0% idle wakes)
  • Mouse input responsive (wake_compositor_if_waiting in HID driver)

🤖 Generated with Claude Code

New compositor_wait syscall (op=23) replaces BWM's polling loop with
kernel-level blocking. BWM now sleeps in the kernel until woken by:
- mark_window_dirty (client rendered new pixels)
- Mouse movement (USB HID handler wakes compositor)
- Window registry change (new/removed window)
- 16ms timeout (keyboard input via stdin poll)

Changes:
- kernel: op=23 compositor_wait with COMPOSITOR_DIRTY_WAKE flag
- kernel: REGISTRY_GENERATION atomic bumped on window register
- kernel: USB HID mouse handler calls wake_compositor_if_waiting()
- kernel: Removed duplicate blocking from op=16 composite_windows
  (compositor_wait now handles all blocking)
- libbreenix: compositor_wait() wrapper returning (ready, registry_gen)
- bwm: Event-driven main loop — only blits when DIRTY flag set,
  only discovers windows when REGISTRY flag set

Results on Parallels ARM64 (1920x1200, 4 windows):
- BWM CPU: 34% → ~20% (41% reduction)
- Bounce FPS: ~130 → ~186 (43% increase)
- Zero idle wakes (was 50% idle polling before)

Combined with MAP_SHARED+occluded blit from previous PR:
- BWM CPU: 70% → ~20% (71% total reduction)
- Bounce FPS: ~100 → ~186 (86% total increase)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ryanbreen ryanbreen merged commit 8417efd into main Mar 10, 2026
1 of 4 checks passed
@ryanbreen ryanbreen deleted the feat/compositor-wait-syscall branch March 10, 2026 08:24
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