Files
chandra/compositor/kms/moon.pkg
Claude 442f9477b4
CI / test (push) Failing after 19s
CPU, round two: cheaper client captures, content-only redraws, damage-limited KMS and nested output
Measured on the MoonBit host, 1080p, cloud container (two runs each, before -> after):
- full-screen (tiled) client redrawing at 60 fps: 43/39% -> 31/35%
- 800x600 floating client at 60 fps: 15.5/13.2% -> 10.4/11.9%
- client inside the nested window: nested 18% -> 12%, outer 17% -> 11.6%
- Alt+Tab open over two animating clients: 36.6% -> 25.4%
- idle (headless / nested): 0.2-0.6% -> 0.1-0.3%

wasmhost raster:
- capture keeps client pools mapped (keyed by dev/inode/size, dropped after 1 s unused) and
  reuses released surface buffers, swizzling a word at a time: 3.2 -> 2.1 ms per 1080p commit.
- a window whose only change is a new buffer damages just its client area, and the topmost
  opaque buffer that covers the damage is drawn first (no backdrop copy, desktop card, lower
  windows or its own decoration under it): submit 3.2 -> 0.8 ms per full-screen frame.
- the framebuffer tracks what changed since each output took it. The nested window's frames
  are a ring of three mapped memfds, each updated only where the screen changed, instead of
  a new memfd with a full 8 MB conversion and write every frame.
- KMS: present copies only the rows the back buffer is missing (this frame's change and the
  last one's), and kms_stub.c is compiled with -O2 (its stub-cc-flags dropped moon's default,
  so the per-frame copy ran unoptimised).
- images re-filled under the same handle (Alt+Tab previews) damage where the panel draws them:
  before, a live preview only repainted where it overlapped the window that redrew.

compositor:
- Alt+Tab previews of a window that keeps redrawing are remade at most every 100 ms (scaling a
  1080p buffer takes ~2 ms); the loop keeps its pace while one is pending.
- set-tokens is sent to the host only when the theme changes (it was 9 calls a frame).
- /proc is sampled only when a module imports `system`; a machine without a battery looks for
  one every 30 s instead of probing eight sysfs paths every second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hkh3qygSXtftCTVhSZ
2026-11-25 21:16:41 +00:00

24 lines
618 B
Plaintext

import {
"moonbitlang/core/builtin",
"chandra/desktop/compositor/renderer" @renderer,
"chandra/desktop/compositor/nested" @nested,
"chandra/desktop/interface/chandra/host/display" @hostdisplay,
}
supported_targets = "+native+wasm"
options(
targets: {
"kms_native.mbt": ["native"],
"kms_wasm.mbt": ["wasm"],
},
"native-stub": [ "kms_stub.c" ],
link: {
"native": {
// -O2: setting stub flags drops moon's default ones, and the per-frame pixel copy into the
// scanout buffer is several times slower unoptimised.
"stub-cc-flags": "-O2 -I/usr/include/libdrm",
},
},
)