# OPTIMIZED Cargo.toml - Rust Compile-Time Optimization Flags # Generated: 2025-10-25 # See: AGENT_15_RUST_COMPILER_OPTIMIZATION_ANALYSIS.md # # USAGE: # 1. Backup current Cargo.toml: cp Cargo.toml Cargo.toml.backup # 2. Review profile changes below (lines 401-460) # 3. Replace [profile.*] sections in main Cargo.toml # 4. Test with: cargo build --release --profile release-pgo # ... (Keep all existing package, dependencies, workspace sections unchanged) # ============================================================================ # OPTIMIZED PROFILE CONFIGURATIONS # ============================================================================ [profile.release] opt-level = 3 # Maximum optimization level lto = "fat" # Whole-program link-time optimization codegen-units = 1 # Single compilation unit for max optimization panic = "abort" # Minimal panic overhead strip = false # CHANGED: Keep symbols for BOLT post-link optimization debug = false # No debug info debug-assertions = false # Runtime checks disabled overflow-checks = false # Math performance optimized # PROFILE-GUIDED OPTIMIZATION (PGO) - RECOMMENDED FOR PRODUCTION # Expected: 5-15% performance improvement in CPU-bound hot paths # Use: cargo pgo build && && cargo pgo optimize [profile.release-pgo] inherits = "release" # No additional flags - PGO metadata handled by cargo-pgo # See: AGENT_15_RUST_COMPILER_OPTIMIZATION_ANALYSIS.md section "Priority 1" # PROFILING BUILDS - Keep debug info for perf profiling # Use: cargo build --release --profile release-profile # Then: perf record -g ./target/release-profile/foxhunt-core [profile.release-profile] inherits = "release" debug = true # Full debug info for symbolization strip = false # Keep all symbols # Note: force-frame-pointers=yes set in .cargo/config.toml (target.profile) # PRODUCTION BUILDS - Zero profiling overhead # Use: cargo build --release --profile release-production # Expected: ~1% improvement vs. release (frame pointer overhead eliminated) [profile.release-production] inherits = "release" strip = true # Remove all symbols for minimal binary size # Note: force-frame-pointers=no (not set in rustflags for this profile) # TEST PROFILE - Fast compilation, zero optimization [profile.test] opt-level = 0 # Disable optimizations for faster test compilation debug = 0 # Remove debug info completely for faster linking debug-assertions = false # Disabled for faster test compilation overflow-checks = false # Disabled for faster test compilation lto = false incremental = true codegen-units = 256 # Maximum parallelism for test builds split-debuginfo = "unpacked" # Faster linking on Linux # DEVELOPMENT PROFILE - Fast iteration [profile.dev] split-debuginfo = "unpacked" # Faster linking for dev builds # BENCHMARK PROFILE - Matches release exactly [profile.bench] inherits = "release" debug = false # HFT PROFILE - High-frequency trading optimized [profile.hft] inherits = "release" opt-level = 3 lto = "fat" codegen-units = 1 panic = "abort" strip = false overflow-checks = false # ============================================================================ # PERFORMANCE OPTIMIZATION NOTES # ============================================================================ # # CURRENT BASELINE: 922x faster than targets (excellent) # OPTIMIZATION POTENTIAL: 12-28% additional performance (average: 22%) # RECOMMENDED APPROACH: Incremental implementation over 1 month # # Phase 1 (Week 1): Quick Wins (7-22% improvement) # 1. PGO: 5-15% improvement (Priority 1) # 2. Static linking: <1% latency, reduced jitter (Priority 2) # 3. Native CPU: 0-5% improvement (Priority 3) # 4. Separate profiles: ~1% improvement (Priority 4) # # Phase 2 (Weeks 2-4): Advanced Optimizations (3-11% improvement) # 5. Allocator tuning: 1-3% improvement (Priority 5) # 6. BOLT post-link: 2-8% improvement (Priority 6) # # TOTAL EXPECTED IMPACT: 1,032-1,180x vs. targets (average: 1,125x) # # See: AGENT_15_RUST_COMPILER_OPTIMIZATION_ANALYSIS.md for full details