Module warmup
Expand description
Cold-start warmup of the font system.
Loading the font system dominates time-to-first-paint on a cold process: the catalog is verified and every installed face mapped, up to ~1s on release builds. Shaping the first text on a background thread, before the first frame needs it, takes that off the critical path:
| Configuration | median first-paint |
|---|---|
| no warmup | 406 ms |
| fonts warmup | 316 ms |
It wins because it never touches the GPU: it shapes strings on a background
thread, building the process’s shared font database so the compositor’s own
configured_font_system call finds it ready. Building the renderer’s
pipelines here instead was measured slower (483 ms): it holds the
process-wide SHARED_RENDER_CONTEXT mutex through its scratch render,
blocking the real renderer’s start on the same lock, so it is not done.
The stages mark through [tilo_startup_metrics::span]: warmup-spawn,
warmup-fonts(-end).
Not persistence: compiled pipelines are kept across launches by
crate::pipeline_cache (the app’s own) and crate::pipeline_seed (the
session’s), where the backend has pipeline caches.
Modules§
- _cosmic_
text - COSMIC Text
Constants§
- CANONICAL_
STRINGS - Canonical strings the warmup shapes through cosmic-text so the per-face shaping caches are populated before the compositor’s first real widget draw. Kept small so the warmup thread stays under ~50ms wall time even on a cold fontconfig cache.
Functions§
- shape_
canonical_ strings - Shape every entry of
CANONICAL_STRINGSthrough the suppliedFontSystem. Populates the internal shape / fallback caches so the first real draw against the sameFontSystemshort-circuits at those cache lookups. - spawn_
warmup - Spawn a detached background worker that builds the process’s shared
FontSystemand shapesCANONICAL_STRINGSagainst it, so the fonts the first frame needs are read and mapped beside the rest of the start.