web-font/rust-spike/Cargo.toml
崮生(子虚) 2044be3a4e perf(rust): 字体加载改 mmap 按需分页,冷读 31ms→1ms、RSS 43MB→4.8MB
- Font.data 改 FontBytes(Owned/Mapped 双形态,Deref 到 &[u8] 下游无感)
- FontCache 用 Mmap::map 替代 fs::read:只把被触及的表页(cmap/loca/字形/GSUB)载入,
  消除全量读盘和「page cache 一份 + 用户堆一份」双倍内存
- unsafe 仅限 mmap 建立/解除一处(字体库静态只读,无并发截断风险),为唯一例外
- 线上验证:容器内存 43MB→8MB,冷 Read 138ms→17ms;TS/LLRT 无 mmap 能力,本项为 rust 运行时专属优化
2026-11-04 20:43:58 +08:00

30 lines
696 B
TOML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[package]
name = "webfont-rs"
version = "0.1.0"
edition = "2024"
[dependencies]
brotli = "9"
memmap2 = "0.9"
[profile.release]
opt-level = 3
lto = "thin"
codegen-units = 1
panic = "unwind"
# 超小二进制发布 profile(目标 3):size 优化 + 全 LTO + 去符号。
# panic 保持 unwind:连接线程 panic 只断当前连接(abort 会因单个畸形请求打死整个服务)
# 禁 unsafe 红线不变;brotli crate 仍限 woff2.rs
[profile.tiny]
inherits = "release"
opt-level = "z"
lto = "fat"
codegen-units = 1
strip = "symbols"
# 小体积但保速变体:opt=3(tiny 的 opt=z 让子集化慢 1.3 倍,速度优先)
[profile.tinyfast]
inherits = "tiny"
opt-level = 3