Course Description
The Rust compiler catches many bugs for you that are common in other languages. Use the tools to avoid bugs and use Rust’s error system to pass meaningful errors and handle them appropriately.
Optimizing Rust
- Measure First: the importance of knowing what to optimize
- Use Rust’s built-in benchmark system to test component performance.
- Use a Profiler to find hotspots.
- When NOT to optimize
- Optimize the Algorithm First
- Optimization levels, Safety, Link Time Optimization.
- Understanding your cache: When Optimizing for Size is faster than Optimizing for Speed.
- Using unsafe safely.
- Profile-Guided Optimization.
- Compiler hints and inlining.
- Tracing distributed components
- Is your microservice too micro?
- Blocking Operations
- Waiting for Databases, File and Network I/O
- Fast, Efficient Logging
Debugging Rust
- Using your tools
- Debugging with println statements.
- Faster printing: tracing with tokio, and fast logging.
- Types of bug
- Attaching a debugger
- Unit testing to avoid bugs in the first place.
- Use Rust’s error system to pass meaningful errors—-and handle them appropriately.
- Avoiding Bugs with the Rust Type System.
- Strong Types, compile-time checking.
- Strong Types, run-time checking.
- Floating point errors.
- Unicode errors.
- Type-conversion errors.
- Always test in debug mode to catch overflow and out-of-bounds errors.
- Memory Issues
- Great Documentation with Rust.
- Integration testing with library examples.