Skip to content

perf(gpu): skip fontconfig for icon fonts and cache font resolution - #80

Merged
piny4man merged 1 commit into
mainfrom
perf/font-resolution
Oct 17, 2026
Merged

piny4man merged 1 commit into
mainfrom
perf/font-resolution

Conversation

@piny4man

Copy link
Copy Markdown
Owner

NUKE-111. resolve_fonts took 39–43 ms on every open, about half of native first presentation. Even with [font] path set, it spawned fc-match monospace and then ran fc-list over all 2875 installed fonts.

Changes

  • If the first font that parses from [font] path or HYPRBURST_FONT already has Nerd Font icons (it has U+F269), fontconfig is skipped. Only the hard-coded fallback paths that exist are kept, for text glyphs the font lacks.
  • Otherwise, the fontconfig answer is cached in $XDG_CACHE_HOME/hyprburst/fonts as plain text, written to a temp file and renamed. It is keyed by the config path, HYPRBURST_FONT and the family, plus the mtimes of ~/.cache/fontconfig and /var/cache/fontconfig. It is looked up again when the key changes, a cached font is gone, or the file is corrupt.
  • resolve_font now returns resolve_fonts(..).primary.
  • docs/hotpath-findings.md gains an "After NUKE-111" section and the table of filed follow-ups. docs/hotpath-profiling.md notes the throwaway open needed before a run.

Results (n=30 per cell, same procedure as #79)

  • resolve_fonts: 39–43 ms before. After: 1.1–1.4 ms when fontconfig is skipped, 1.4–2.2 ms on a cache hit. An uncached lookup still costs 30–40 ms, once after fonts change.
  • First-content p95 drops by 40–51 ms for both frontends in both profiles. Native: cold 86.0 → 42.9 ms in performance and 94.0 → 46.9 ms in balanced.
  • All four balanced-vs-performance first-presentation targets now pass: cold native +9.4%, warm native +6.3% (the failure tracked in NUKE-115), cold Rio +3.9%, warm Rio −0.6%.

Validation

  • cargo fmt --check.
  • Clippy with -D warnings, default features and --all-features.
  • cargo test --all-targets with default, hotpath and hotpath-alloc features: 323 / 324 / 324 passed, 9 new font tests.
  • Manually checked: skip path with the real config; cache miss, then hit, in a sandboxed XDG_CACHE_HOME; touch on the fontconfig cache dir forces a new lookup.

resolve_fonts cost 39-43 ms on every open, about half of native first
presentation: even with `[font] path` set it spawned `fc-match
monospace` and, because the default mono is not a Nerd Font, an
`fc-list` scan of every installed font.

- When the first parseable `[font] path` / HYPRBURST_FONT font already
  has Nerd Font icons, fontconfig is skipped; only the hard-coded
  fallback paths that exist are kept for missing text glyphs.
- Otherwise the fontconfig answer is cached in
  $XDG_CACHE_HOME/hyprburst/fonts, keyed by the font inputs and the
  fontconfig cache directories' mtimes, and looked up again when the
  key changes or a cached font no longer exists.

resolve_fonts is now 1.1-2.2 ms. First-content p95 (n=30) drops by
40-51 ms for both frontends in performance and balanced, and every
balanced-vs-performance first-presentation target now passes.
docs/hotpath-findings.md records the re-measure and links the filed
follow-ups.
@piny4man
piny4man merged commit ed14bcb into main Oct 17, 2026
1 check passed
@piny4man
piny4man deleted the perf/font-resolution branch October 17, 2026 09:33
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