Repository navigation
perf: share one font store per font configuration across the process - #56
Merged
evolvedlight merged 1 commit intoOct 17, 2026
Merged
Conversation
Every compiler scanned the system fonts and built its own FontStore. The scan is most of what creating a compiler costs, so the one-shot helpers paid it on every call, and each compiler kept its own copy of every font it loaded. Stores are now cached process-wide, keyed by whether system fonts are included and the font directories. With system fonts enabled, create, compile and free of a short document went from 71-77 ms to 1.4-1.8 ms after the first call. A font installed after a configuration was first used is not seen until the process restarts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every
TypstCompilerscanned the system fonts and built its ownFontStore. That scan is most of what creating a compiler costs, so the static one-shot helpers (TypstCompiler.CompilePdf(source)and the like) paid for it on every call. Each live compiler also kept its own copy of every font it loaded.Font stores are now cached for the whole process, keyed by
IncludeSystemFontsand the font directories.SystemWorldreads its font book straight from the shared store, so the separate per-world copy of the book is gone.Measured with system fonts enabled, creating a compiler, compiling a short PDF and freeing it, release build on Windows:
Trade-offs, also noted in the release notes and on the
Fontsrecord:EvictCache()does not release them.Tests: new unit tests check that worlds with the same configuration share a store, that the store outlives its worlds, and that different configurations get different stores.
cargo test --releasepasses, and so do all 80 .NET tests.