atagen

monolith

public
Star0
Watch0

Commit 9c83f07146b1

tarball

atagen <boss@atagen.co>2026-10-16 13:37 UTC

2 files changed+56-48
monolith: hold the render slack at the level that last proved enough

Decaying freely, the slack crept back below what the GPU and commit need and dropped a frame every few seconds to find that out again. After a miss it now stays at the raised level for 30 seconds before decaying further.
Modified file: crates/monolith/src/drm.rs+17 additions−4 deletions
@@ -96,6 +96,11 @@ impl Surface {
9696 struct Budget {
9797 renders: VecDeque<u64>,
9898 slack_ns: u64,
99+ /// The slack that last proved enough after a miss. Decay stops there
100+ /// for `floor_frames` frames, so it does not keep rediscovering the same
101+ /// limit one dropped frame at a time.
102+ floor_ns: u64,
103+ floor_frames: u64,
99104 }
100105
101106 impl Budget {
@@ -103,11 +108,14 @@ impl Budget {
103108 const MIN_SLACK_NS: u64 = 1_000_000;
104109 const STEP_NS: u64 = 500_000;
105110 const DECAY_NS: u64 = 1_000;
111+ const FLOOR_NS: u64 = 30_000_000_000;
106112
107113 fn new() -> Self {
108114 Self {
109115 renders: VecDeque::with_capacity(Self::KEEP),
110116 slack_ns: 2_000_000,
117+ floor_ns: 0,
118+ floor_frames: 0,
111119 }
112120 }
113121
@@ -130,13 +138,18 @@ impl Budget {
130138
131139 fn missed(&mut self, refresh_ns: u64) {
132140 self.slack_ns = (self.slack_ns + Self::STEP_NS).min(refresh_ns / 2);
141+ self.floor_ns = self.slack_ns;
142+ self.floor_frames = Self::FLOOR_NS / refresh_ns.max(1);
133143 }
134144
135145 fn landed(&mut self) {
136- self.slack_ns = self
137- .slack_ns
138- .saturating_sub(Self::DECAY_NS)
139- .max(Self::MIN_SLACK_NS);
146+ self.floor_frames = self.floor_frames.saturating_sub(1);
147+ let floor = if self.floor_frames > 0 {
148+ self.floor_ns
149+ } else {
150+ Self::MIN_SLACK_NS
151+ };
152+ self.slack_ns = self.slack_ns.saturating_sub(Self::DECAY_NS).max(floor);
140153 }
141154 }
142155
Modified file: monolith.log+39 additions−44 deletions
@@ -1,48 +1,43 @@
11 Finished `release` profile [optimized] target(s) in 0.06s
22 Running `target/release/monolith run --backend drm , vkcube`
3-2026-10-16T13:32:43.669264Z INFO monolith::drm: primary GPU path=/dev/dri/card1
4-2026-10-16T13:32:43.906857Z INFO monolith::drm: output connected name="DP-2" w=2560 h=1440 refresh=165
5-2026-10-16T13:32:43.906934Z INFO monolith::ipc: control socket path=/run/user/1000/monolith-wayland-2.sock
6-2026-10-16T13:32:43.906946Z INFO monolith: monolith running socket="wayland-2" device="NVIDIA GeForce RTX 3060"
7-2026-10-16T13:32:43.907346Z INFO monolith::commands: spawned pid=348266 argv=[",", "vkcube"]
8-2026-10-16T13:32:43.927078Z DEBUG monolith::drm: slow frame output="DP-2" took_ns=19657007 scene_ns=1950 render_ns=12420942 queue_ns=156392
9-2026-10-16T13:32:43.931073Z DEBUG monolith::drm: frame rate output="DP-2" presented=1 vblanks=8493716 budget_us=21657
3+2026-10-16T13:35:15.490106Z INFO monolith::drm: primary GPU path=/dev/dri/card1
4+2026-10-16T13:35:15.730968Z INFO monolith::drm: output connected name="DP-2" w=2560 h=1440 refresh=165
5+2026-10-16T13:35:15.731044Z INFO monolith::ipc: control socket path=/run/user/1000/monolith-wayland-2.sock
6+2026-10-16T13:35:15.731056Z INFO monolith: monolith running socket="wayland-2" device="NVIDIA GeForce RTX 3060"
7+2026-10-16T13:35:15.731475Z INFO monolith::commands: spawned pid=349343 argv=[",", "vkcube"]
8+2026-10-16T13:35:15.752875Z DEBUG monolith::drm: slow frame output="DP-2" took_ns=21319632 scene_ns=1670 render_ns=9734952 queue_ns=96181
9+2026-10-16T13:35:15.753292Z DEBUG monolith::drm: frame rate output="DP-2" presented=1 vblanks=8518760 budget_us=23319
1010 Selected WSI platform: wayland
1111 Selected GPU 0: NVIDIA GeForce RTX 3060, type: DiscreteGpu, apiVersion: 4211017 (1.4.329), driverVersion: -1797652352 (83.416.128)
12-2026-10-16T13:32:44.610017Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=18188851 budget_ns=2858445
13-2026-10-16T13:32:44.931284Z DEBUG monolith::drm: frame rate output="DP-2" presented=73 vblanks=164 budget_us=2745
14-2026-10-16T13:32:45.931531Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2582
15-2026-10-16T13:32:46.931788Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=2426
16-2026-10-16T13:32:47.932040Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2295
17-2026-10-16T13:32:47.944211Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=6066851 budget_ns=2823926
18-2026-10-16T13:32:48.932319Z DEBUG monolith::drm: frame rate output="DP-2" presented=164 vblanks=165 budget_us=2656
19-2026-10-16T13:32:49.914539Z DEBUG monolith::input: bind cmd=Fullscreen
20-2026-10-16T13:32:49.932555Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2420
21-2026-10-16T13:32:49.998732Z DEBUG monolith::drm: slow frame output="DP-2" took_ns=10737116 scene_ns=9140 render_ns=10458842 queue_ns=265194
22-2026-10-16T13:32:50.005318Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=42439255 budget_ns=2869784
23-2026-10-16T13:32:50.017443Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=6061851 budget_ns=3300398
24-2026-10-16T13:32:50.672080Z DEBUG monolith::drm: slow frame output="DP-2" took_ns=3180736 scene_ns=6370 render_ns=3057454 queue_ns=114512
25-2026-10-16T13:32:50.678316Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=6140851 budget_ns=3361459
26-2026-10-16T13:32:50.932811Z DEBUG monolith::drm: frame rate output="DP-2" presented=152 vblanks=165 budget_us=3385
27-2026-10-16T13:32:51.933167Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=3136
28-2026-10-16T13:32:52.933320Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2925
29-2026-10-16T13:32:53.933574Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=2783
30-2026-10-16T13:32:54.933829Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2704
31-2026-10-16T13:32:55.743499Z DEBUG monolith::input: bind cmd=Fullscreen
32-2026-10-16T13:32:55.823060Z DEBUG monolith::drm: slow frame output="DP-2" took_ns=9146473 scene_ns=9791 render_ns=8938449 queue_ns=194353
33-2026-10-16T13:32:55.831041Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=36380106 budget_ns=2949527
34-2026-10-16T13:32:55.873474Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=6067851 budget_ns=3237817
35-2026-10-16T13:32:55.934079Z DEBUG monolith::drm: frame rate output="DP-2" presented=153 vblanks=164 budget_us=3322
36-2026-10-16T13:32:56.934342Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=3193
37-2026-10-16T13:32:56.952632Z DEBUG monolith::drm: slow frame output="DP-2" took_ns=3303388 scene_ns=6890 render_ns=3235347 queue_ns=59391
38-2026-10-16T13:32:56.958585Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=6060851 budget_ns=3377249
39-2026-10-16T13:32:57.145476Z DEBUG monolith::input: bind cmd=Spawn { argv: ["beer"] }
40-2026-10-16T13:32:57.146181Z INFO monolith::commands: spawned pid=348279 argv=["beer"]
41-2026-10-16T13:32:57.303481Z DEBUG monolith::drm: slow frame output="DP-2" took_ns=15769221 scene_ns=15331 render_ns=15528617 queue_ns=222093
42-2026-10-16T13:32:57.304343Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=48504851 budget_ns=3458460
43-2026-10-16T13:32:57.934592Z DEBUG monolith::drm: frame rate output="DP-2" presented=156 vblanks=164 budget_us=3238
44-2026-10-16T13:32:58.934858Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=3074
45-2026-10-16T13:32:59.935104Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2911
46-2026-10-16T13:33:00.935356Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2688
47-2026-10-16T13:33:01.853414Z DEBUG monolith::input: bind cmd=Quit
48-Io error: Broken pipe (os error 32)
12+2026-10-16T13:35:16.450434Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=24230851 budget_ns=2803045
13+2026-10-16T13:35:16.753596Z DEBUG monolith::drm: frame rate output="DP-2" presented=69 vblanks=165 budget_us=2738
14+2026-10-16T13:35:17.753796Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2632
15+2026-10-16T13:35:18.754050Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2449
16+2026-10-16T13:35:19.754328Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=2236
17+2026-10-16T13:35:19.790784Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=6078851 budget_ns=2755525
18+2026-10-16T13:35:20.754562Z DEBUG monolith::drm: frame rate output="DP-2" presented=164 vblanks=164 budget_us=2552
19+2026-10-16T13:35:21.754869Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=2615
20+2026-10-16T13:35:22.372840Z DEBUG monolith::input: bind cmd=Fullscreen
21+2026-10-16T13:35:22.449190Z DEBUG monolith::drm: slow frame output="DP-2" took_ns=6973660 scene_ns=4561 render_ns=6779016 queue_ns=188123
22+2026-10-16T13:35:22.452000Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=30322255 budget_ns=2938557
23+2026-10-16T13:35:22.470172Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=6065851 budget_ns=3437557
24+2026-10-16T13:35:22.506619Z DEBUG monolith::drm: slow frame output="DP-2" took_ns=3565205 scene_ns=4030 render_ns=3479754 queue_ns=78911
25+2026-10-16T13:35:22.512598Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=6056851 budget_ns=3538122
26+2026-10-16T13:35:22.755071Z DEBUG monolith::drm: frame rate output="DP-2" presented=154 vblanks=164 budget_us=3382
27+2026-10-16T13:35:23.755325Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=3137
28+2026-10-16T13:35:24.755593Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=2998
29+2026-10-16T13:35:25.755884Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=2771
30+2026-10-16T13:35:26.756094Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2601
31+2026-10-16T13:35:27.756410Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=2467
32+2026-10-16T13:35:28.726318Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=6060851 budget_ns=2822079
33+2026-10-16T13:35:28.756635Z DEBUG monolith::drm: frame rate output="DP-2" presented=164 vblanks=164 budget_us=2896
34+2026-10-16T13:35:29.756859Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2563
35+2026-10-16T13:35:30.757118Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=2401
36+2026-10-16T13:35:31.757402Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=2363
37+2026-10-16T13:35:32.757640Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=2124
38+2026-10-16T13:35:33.757961Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=165 budget_us=1931
39+2026-10-16T13:35:34.758162Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=1773
40+2026-10-16T13:35:34.940003Z DEBUG monolith::drm: frame missed its vblank output="DP-2" late_ns=6042851 budget_ns=2282459
41+2026-10-16T13:35:35.758521Z DEBUG monolith::drm: frame rate output="DP-2" presented=164 vblanks=165 budget_us=2348
42+2026-10-16T13:35:36.758685Z DEBUG monolith::drm: frame rate output="DP-2" presented=165 vblanks=164 budget_us=1960
43+2026-10-16T13:35:37.231640Z DEBUG monolith::input: bind cmd=Quit