A high-throughput, concurrent Go renderer for compiling Typst source into PDF bytes.
The project focus is simple: generate PDFs as fast as possible with predictable throughput.
- Accepts Typst source as a string.
- Uses worker goroutines to compile source in parallel.
- Calls the Typst CLI (
typst compile - -) and returns PDF bytes. - Streams successful renders and errors through channels.
Optimize for high PDF rendering speed.
This repository does not aim to be a PDF management system.
It intentionally skips product features such as:
- PDF identity/tracking workflows.
- Document lifecycle and storage concerns.
- Metadata-heavy or business process features.
- Go 1.26+
- Typst CLI installed and available in
PATH
Verify Typst installation:
typst --versiongo mod tidygo test -bench=. -benchmem -benchtime=10s -cpu=12 ./rendererMeasured on: Linux (amd64), AMD Ryzen 5 5600H Date: 2026-04-21
Stress run output (from go run .):
Starting stress test: 1000 runs | 12 workers | 24 buffer
=====================================
Total Time taken : 11.077930344s
Avg Time taken : 11.00
Success Rate : 1000/1000
Error Rate : 0/1000
Throughput : 90.27 PDFs/sec
=====================================
Benchmark command used:
go test -bench=. -benchmem -benchtime=10s -cpu=12 ./rendererObserved benchmark output:
goos: linux
goarch: amd64
pkg: github.com/iamharshdabas/typst/renderer
cpu: AMD Ryzen 5 5600H with Radeon Graphics
BenchmarkRenderer/W:6/Ratio:2x(Buf:12)-12 754 15696553 ns/op 0.12 MB/s 179758 B/op 115 allocs/op
PASS
ok github.com/iamharshdabas/typst/renderer 13.514s
Notes:
- Peak measured throughput in this repo:
90.27 PDFs/secon a 1000-PDF stress run. - Average latency during that run: about
11 ms/pdf. - Thermal throttling directly affects sustained throughput.
flowchart TD
A[Caller invokes CreatePDF with Typst source] --> B[Source pushed to input channel]
B --> C[Worker goroutine reads source]
C --> D[Run typst compile - -]
D --> E{Compile success?}
E -->|Yes| F[Send PDF bytes to OutputChan]
E -->|No| G[Send error to ErrorChan]
F --> H[Consumer handles rendered PDF]
G --> I[Consumer logs/handles failure]
H --> J[WaitAndClose drains and closes channels]
I --> J
main.go demonstrates a stress test that:
- Loads Typst source from
renderer/file.typ - Uses
runtime.NumCPU()workers - Submits 1000 render requests
- Reports success/error counts and throughput
Run it with:
go run .- Start with
workers = runtime.NumCPU(). - Keep channel buffers near
workers * 2as a baseline. - Benchmark with your real Typst templates, not only synthetic/simple docs.
- Track error rate while increasing throughput.
This project is effectively complete for its goal: maximizing Typst-to-PDF throughput.
No further work is planned. Treat this as a focused performance experiment, not a full PDF platform.