Skip to content

fontique: parallelize file system font scanning with sparse reads - #3

Open
nicoburns wants to merge 2 commits into
mainfrom
devin/1785890299-parallel-font-scan
Open

fontique: parallelize file system font scanning with sparse reads#3
nicoburns wants to merge 2 commits into
mainfrom
devin/1785890299-parallel-font-scan

Conversation

@nicoburns

Copy link
Copy Markdown
Member

Summary

Speeds up ScannedCollection::from_paths (used for system font enumeration on macOS/Android and load_fonts_from_paths) by restructuring the scan into three phases:

  1. collect_font_files: walk the given paths up front into a deduplicated file list.
  2. parse_files: parse files in parallel across available_parallelism() threads (std::thread::scope + an atomic cursor for work stealing), each producing plain FontRecord { names, postscript_name, font } values.
  3. Merge records into the FamilyNameMap/FamilyInfo/postscript-name maps on the calling thread (these maps allocate runtime IDs and aren't thread-safe).

Per-file parsing also switches from mmap to positioned read calls (mmap page faults serialize in the kernel, defeating parallelism). Rather than reading whole files, read_font_metadata reads only what scanning needs — header, TTC directory, table directories, and the name/OS/2/head/post/fvar/cmap tables — merging overlapping ranges and placing them at their original offsets in a sparse buffer so FontRef::from_index sees a normal font. This matters for large fonts (CJK, emoji, .ttc collections) where metadata is a tiny fraction of the file.

Behavior is preserved: same family/alias/postscript-name results, hvgl fonts still rejected, invalid fonts skipped. Verified on Linux that the sparse-read parse produces byte-identical results (indices, names, postscript names, charmap offsets) to the previous mmap scan across all 236 system font files including a .ttc.

Note: I can only cross-compile for macOS from this environment (clippy/check pass for aarch64-apple-darwin, Windows, wasm, Linux, and a no-std target); real-world timing on macOS still needs to be measured. Stacked PR adding a persistent scan cache follows.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/60a3d833a0894a73945c806adff1cbf3
Requested by: @nicoburns

@nicoburns nicoburns self-assigned this Aug 5, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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