From bc6b8665fa0254bedfaf13c00d4ce8f6b62ebd3f Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Fri, 19 Jun 2026 14:30:29 +0800 Subject: [PATCH] perf: strip + thin-LTO + single codegen-unit for release builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The release profile was unset, leaving Rust defaults (no LTO, codegen-units=16, symbols kept) → a ~70 MB desktop binary. strip + lto=thin + codegen-units=1 cut it to ~55.5 MB (-20%). opt-level stays at 3 (native and wasm both run the hot paint/layout loop); panic=abort deferred pending a worker thread-isolation audit. --- Cargo.toml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 94bd21994..07dff231b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,3 +42,25 @@ tracing = "0.1" # resolve to upstream crates.io 0.97.0 — used only by the native desktop host # (`op-host-desktop`) + `jian-skia`, where the fork was byte-identical anyway. # No `[patch.crates-io]` needed. + +# Release profile. Previously unset → Rust defaults (no LTO, codegen-units=16, +# symbols kept), which shipped a ~70 MB desktop binary. This governs every +# release build in the graph, including the excluded vendor/* path deps (their +# own [profile.release] blocks are inert — only the build-root profile applies). +[profile.release] +# `strip` removes the symbol table — measured ~7.5 MB off the native binary, and +# trims the wasm too (the production web bundle never needs symbol names). +strip = true +# Cross-crate inlining + dedup of monomorphized generics (e.g. PenNode::clone is +# duplicated ~20× without it). "thin" gets most of the win at a fraction of the +# fat-LTO link time. +lto = "thin" +# Lets the backend dedup within each crate; compounds with LTO. Costs release +# build time (single-threaded codegen of the big crates) — acceptable for the +# infrequent shippable/CI builds this profile targets. +codegen-units = 1 +# opt-level is intentionally LEFT AT 3 (the default), NOT "s"/"z": both the +# native and the wasm builds run the hot paint/layout/hit-test loop, and +# size-opt levels measurably slow it. panic = "abort" is also intentionally NOT +# set yet — it needs a thread-isolation audit of the chat/codegen workers, some +# of which rely on unwinding to contain a panicking task.