Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Performance Tips

Quick reference for optimizing your AstraWeave games. For in-depth performance optimization, see the Performance Guide.

Quick Wins

Build Configuration

Always use release builds for performance testing:

cargo run --release -p your_game

Common Optimizations

IssueSolution
Low FPSUse release builds, reduce entity count
High memoryLimit AI memory buffers, use asset streaming
AI lagIncrease planning interval, reduce perception range
Render stutterEnable frustum culling, use LODs

AI Performance

#![allow(unused)]
fn main() {
ai_config.planning_interval = Duration::from_millis(500);
ai_config.perception_range = 15.0;
ai_config.max_concurrent_llm_requests = 2;
}

ECS Batching

Process entities in batches:

#![allow(unused)]
fn main() {
fn process_entities(query: Query<(&Transform, &mut Velocity)>) {
    query.par_iter_mut().for_each(|(transform, mut velocity)| {
        velocity.0 = calculate_velocity(transform);
    });
}
}

Performance Targets

MetricTargetMeasurement
Frame time< 16.67ms60 FPS
AI tick< 5msPlanning + execution
Physics step< 4msCollision + dynamics
Render< 8msDraw calls + GPU

Profiling Tools

  • Tracy: Real-time frame profiler
  • Cargo flamegraph: CPU profiling
  • RenderDoc: GPU debugging
cargo install cargo-flamegraph
cargo flamegraph --release -p your_game

See Also