Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- `compiler.CompilePdf(Stream)`, `compiler.CompilePdfAsync(Stream)`, `compiler.CompilePdf(string outputFile)` and `compiler.CompilePdfAsync(string outputFile)` now stream the document straight from native memory to the destination and return the compiler warnings, rather than returning a `PdfResult` that had to be materialised on the managed heap first. Use `compiler.CompilePdf()` when you want the bytes.
- `compiler.Compile(outputFile, format)` and `compiler.CompileSvg(...)` no longer copy the rendered output onto the managed heap before writing or decoding it.
- `sysInputs` parameters on `TypstCompiler` and the `SetSysInputs` argument are now `IDictionary<string, string>` instead of `Dictionary<string, string>`, so a `ReadOnlyDictionary<string, string>`, `ImmutableDictionary<string, string>` or any other implementation can be passed. Existing calls that pass a `Dictionary<string, string>` are unaffected.
- The native library is now built with the release settings Typst itself uses, thin LTO and a single codegen unit, which makes it about 6% smaller: the Windows x64 `typst_core.dll` measured 51.6 MB before and 48.3 MB after. Compile speed is unchanged within measurement noise.

### Added
- Added `TypstCompiler.EvictCache()` to clear and release the memory held by Typst's incremental compilation cache. The cache is shared by the whole process and was only ever trimmed to what the last ten compilations used, so an application that compiled one large document kept memory in proportion to it for the next ten compilations, and could not release it any sooner. The cache is process-wide, so clearing it makes the next compilation of every compiler start cold; it is safe while other threads compile, and leaves compiled documents valid. The packaged Linux library uses musl, which reuses the freed memory rather than returning it to the operating system, and a single compilation's peak is unchanged, so a very large document still has to be split to bound that.
Expand Down
11 changes: 10 additions & 1 deletion src/typst_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ typst-html = "0.15.1"
typst-layout = "0.15.1"

[build-dependencies]
csbindgen = "1.9.7"
csbindgen = "1.9.7"

# The settings Typst itself is released with. A single codegen unit and thin LTO let
# the optimiser see across crate boundaries and drop what the exported functions never
# reach, which makes the native library about 6% smaller. Speed is within measurement
# noise. The cost is a slower release build. `panic` must stay at its default,
# `unwind`: `compile` catches panics so that they never cross the C ABI.
[profile.release]
lto = "thin"
codegen-units = 1
Loading