tilo_render_protocol/limits.rs
1//! What one app may ask of its workspace's render service.
2//!
3//! Every number bounds work the service would otherwise do on an app's
4//! behalf, for every app in the workspace: an app over a limit gets that frame
5//! dropped and a diagnostic ([`crate::control::ServiceMessage::FrameDropped`]),
6//! never a stalled service. The defaults hold every toolkit frame measured
7//! (a dense Notes page encodes ~400 KB, ~6 000 paths) with an order of
8//! magnitude to spare; the service may lower them for a workspace under pressure.
9
10use serde::{Deserialize, Serialize};
11
12/// Per-app bounds the service enforces on records and resources.
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
14pub struct Limits {
15 pub frame_bytes: u32,
16 /// Bytes of the ring an app may map into the service.
17 pub ring_bytes: u32,
18 /// Paths in one frame, all layers and backdrops together.
19 pub paths: u32,
20 /// Path segments in one frame, after glyphs are expanded estimates.
21 pub segments: u32,
22 pub draw_objects: u32,
23 /// Glyphs in one frame.
24 pub glyphs: u32,
25 pub clip_depth: u32,
26 /// Layers one surface keeps.
27 pub layers: u32,
28 /// Surfaces one connection keeps.
29 pub surfaces: u32,
30 pub surface_edge: u32,
31 /// Pixels of all of a connection's surfaces together; their render
32 /// targets and buffers are the service's GPU memory spent on the app.
33 pub surface_pixels: u64,
34 /// Bytes of all images one connection keeps registered. They live in
35 /// memfds the app created, so its cgroup pays for them; this bounds what
36 /// the service maps and uploads.
37 pub image_bytes: u64,
38 pub images: u32,
39 /// Fonts one connection keeps registered.
40 pub fonts: u32,
41 /// Bytes of one font an app uploads itself (fonts from the shared view
42 /// are mapped from their files and not counted).
43 pub font_bytes: u64,
44 /// GPU time one frame may take, in microseconds. A frame over it is
45 /// presented, then the app's next frames wait out the overrun, so one app
46 /// cannot take the room's GPU from the others.
47 pub gpu_time_us: u32,
48 /// Backdrop regions one frame blurs.
49 pub backdrops: u32,
50 /// Damage rectangles and scroll copies one frame lists.
51 pub rects: u32,
52}
53
54impl Default for Limits {
55 fn default() -> Self {
56 Self {
57 frame_bytes: 16 << 20,
58 ring_bytes: 64 << 20,
59 paths: 200_000,
60 segments: 4_000_000,
61 draw_objects: 200_000,
62 glyphs: 200_000,
63 clip_depth: 64,
64 layers: 256,
65 surfaces: 32,
66 surface_edge: 16_384,
67 surface_pixels: 64 << 20,
68 image_bytes: 1 << 30,
69 images: 16_384,
70 fonts: 1_024,
71 font_bytes: 64 << 20,
72 gpu_time_us: 50_000,
73 backdrops: 4,
74 rects: 4_096,
75 }
76 }
77}