perf: optimize binary size and performance with release profile#88
perf: optimize binary size and performance with release profile#88
Conversation
Add comprehensive release profile optimization settings: - opt-level=3: Maximum optimization for performance - lto=true: Link-time optimization for both performance and size - codegen-units=1: Single codegen unit for better optimization - strip=true: Remove debug symbols to reduce binary size - Dependencies optimized with opt-level="s" for size efficiency Results: - samoyed: 1.7M → 1013K (40% size reduction) - samoyed-hook: 479K → 365K (24% size reduction) - All 258 tests continue to pass - Maintains panic unwinding for better library compatibility
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive release profile optimization settings to Cargo.toml to improve binary size and runtime performance. The implementation uses a balanced approach with maximum optimization for the main binary and size optimization for dependencies.
- Added release profile with LTO, single codegen unit, and symbol stripping
- Configured dependencies to optimize for size while main binary optimizes for performance
- Updated pre-push hook to include clippy checks for better code quality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Cargo.toml | Added release profile optimization settings with LTO and size/performance balance |
| samoyed.toml | Enhanced pre-push hook to include clippy checks alongside existing tests |
🔒 Security Audit Report❌ Error parsing audit report Could not parse security audit results. Check the logs for details. Security audit performed by cargo-audit |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📊 Performance Test ReportTest Environment: Ubuntu Latest (GitHub Actions) 📏 Binary Size Analysis (AC8.2)
🧠 Memory Usage Analysis (AC8.3)
⚡ Performance Benchmarks
📈 Performance Summary
Full benchmark results available in workflow artifacts. |
Switch from opt-level=3 to opt-level="z" for maximum size reduction: - Prioritizes size over speed for both main crate and dependencies - More aggressive size optimizations compared to previous settings - Maintains LTO, codegen-units=1, and strip=true - All tests continue to pass Binary size comparison: - Previous: samoyed 1013K, samoyed-hook 365K - Expected: Further size reduction with minimal performance impact
🔒 Security Audit Report❌ Error parsing audit report Could not parse security audit results. Check the logs for details. Security audit performed by cargo-audit |
📊 Performance Test ReportTest Environment: Ubuntu Latest (GitHub Actions) 📏 Binary Size Analysis (AC8.2)
🧠 Memory Usage Analysis (AC8.3)
⚡ Performance Benchmarks
📈 Performance Summary
Full benchmark results available in workflow artifacts. |
Update version from 0.1.9 to 0.1.10 with optimized binary sizes: - samoyed: 921K (46% reduction from original 1.7M) - samoyed-hook: 345K (28% reduction from original 479K) - All tests continue to pass with size-optimized build profile
🔒 Security Audit Report❌ Error parsing audit report Could not parse security audit results. Check the logs for details. Security audit performed by cargo-audit |
📊 Performance Test ReportTest Environment: Ubuntu Latest (GitHub Actions) 📏 Binary Size Analysis (AC8.2)
🧠 Memory Usage Analysis (AC8.3)
⚡ Performance Benchmarks
📈 Performance Summary
Full benchmark results available in workflow artifacts. |
Fix contributor mapping in changelog generation to use correct GitHub usernames: - Map emails ([email protected], [email protected]) to @behrangsa - Avoid incorrect @mentions for unknown contributors - Prevents generating @behrang Saeedzadeh which mentions wrong user - Ensures proper attribution to @behrangsa in release notes
🔒 Security Audit Report❌ Error parsing audit report Could not parse security audit results. Check the logs for details. Security audit performed by cargo-audit |
📊 Performance Test ReportTest Environment: Ubuntu Latest (GitHub Actions) 📏 Binary Size Analysis (AC8.2)
🧠 Memory Usage Analysis (AC8.3)
⚡ Performance Benchmarks
📈 Performance Summary
Full benchmark results available in workflow artifacts. |
Summary
Optimize binary size and performance by adding comprehensive release profile settings to Cargo.toml. This implementation prioritizes maximum size reduction while maintaining functionality and library compatibility.
� Add release profile with size-focused optimization settings
� Enable Link-Time Optimization (LTO) for better performance and size reduction
� Configure single codegen unit for optimal optimization
� Enable automatic symbol stripping
� Use opt-level="z" for maximum size reduction
� Optimize all dependencies for size efficiency
� Maintain panic unwinding for better library compatibility
� Verify all 258 tests continue to pass
Binary Size Improvements
Total size reduction: 43% average across both binaries
Optimization Settings
Design Decisions
panic = "abort": Maintains panic unwinding for better library compatibility and resource cleanupWhat is LTO? (ELI5)
Link-Time Optimization is like organizing your entire house after moving in:
In code terms: LTO looks at your entire program after compilation and removes unused functions, eliminates duplicate code, and makes cross-function optimizations that weren't possible when compiling files separately.
Test Plan
� All 258 unit tests pass
� All integration tests pass
� Benchmarks compile and run successfully
� Doc tests continue to work
� Cross-platform tests pass (Linux, macOS, Windows)
� Pre-commit hooks execute successfully
Performance Impact