What is the best way to track down what is slowing down compilation in a Typst project? Are there any packages or built-in approaches to identify where optimization needs to be done?
I’m creating 200 versions of an assignment about phylogenetic trees (project linked here, with assignment answers obscured). Each version includes a unique tree made using a fletcher diagram. To make unique versions, I’m using suiji to randomly sample subsets of an array of ~40 species. Each subset is used to make one assignment version. However, in the web app, generating 100 versions takes over 1.5 mins, and attempting to generate 200 versions did not give me any result after 5 mins. I have several ideas of where this slow-down might be occurring, but trial-and-error testing for slowdown points takes a very long time, obviously.
Thanks for your reply. Generating 200 assignments via the CLI was much slower for me, over 5.5 mins. Maybe the difference between us comes down to hardware.
Regardless, I am hoping to more broadly be able to find what is slowing down compilation for a given document. Is that something that exists for Typst?
--timings [<OUTPUT_JSON>]
Produces performance timings of the compilation process.
(experimental)
The resulting JSON file can be loaded into a tracing tool such as
https://ui.perfetto.dev. It does not contain any sensitive information
apart from file names and line numbers.
Without what tooling? The docs say how to use it. However, the bigger the document, the longer it takes to save the timings, and the bigger they get. You can try it on some small portion of the document and increase it, if needed.
If the difference is that large, I would suspect incremental compilation makes the difference. typst compile always starts from scratch (typst watch doesn’t, and the web app’s document compilation cycle seems to work similarly to typst watch).
Thanks all, I reduced the number of assignments to 10 and ran the following:
typst c main.typ --timings --jobs 1
I obviously have a lot more to learn about how Typst works before I can understand the output well, but at least I’m pretty certain that fletcher and cetz are the biggest slowdowns here.
if your figures won’t change, or don’t change for every generation, then you can always pre-generate them from a separate document first, and use the output in your documents.