Skip to content

Commit 1e1c2c1

Browse files
committed
feat: optimize binary size with Cargo profile settings
- Add [profile.release] section with size optimization flags - opt-level = 'z' for size optimization - lto = true for link-time optimization - strip = 'debuginfo' to remove debug symbols - panic = 'abort' to remove panic unwinding code - codegen-units = 1 for better optimization - overflow-checks = true for safety Results: - Binary size reduced from 7.5MB to 4.5MB (40% reduction) - Docker image size reduced from 141MB to 136MB - Tracing functionality preserved and working correctly
1 parent b907eb6 commit 1e1c2c1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,17 @@ phf_codegen = "0.12.1"
4141
serde = { version = "1.0.204", features = ["derive"] }
4242
saphyr = "0.0.6"
4343
reqwest = { version = "0.12.5", features = ["blocking"] }
44+
45+
[profile.release]
46+
# Optimize for size
47+
opt-level = "z"
48+
# Enable link-time optimization for better size reduction
49+
lto = true
50+
# Strip debug symbols (but keep panic info for tracing)
51+
strip = "debuginfo"
52+
# Use panic = "abort" to reduce binary size (removes panic unwinding code)
53+
panic = "abort"
54+
# Enable codegen units optimization
55+
codegen-units = 1
56+
# Keep overflow checks for safety
57+
overflow-checks = true

0 commit comments

Comments
 (0)