Dev fixes 334x slowdown in Typst's convergence check by deduplicating introspections
A performance regression in Typst 0.15.0 caused compile times on a 300-page document to balloon from 1 minute 17 seconds to 14 minutes, while peak memory usage rose from 32GB to 41GB. The bottleneck was traced to a new step called 'analyze introspections,' which re-executed every recorded introspection six times to check for convergence, resulting in roughly 70 million re-executions on documents with millions of introspections. Investigation revealed that the recording mechanism used a push-only list with no deduplication, despite the introspection types already implementing the interfaces needed for equality checks. The fix involved collapsing duplicate introspections before analysis, since several introspection types carry no per-element location data and can safely repeat. The result was a 334x speedup in the convergence check, achieved without altering Typst's correctness or warning output.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in