I Made Zig Compute 33M Satellite Positions in 3 Seconds. No GPU Required
3 months ago
- #Zig
- #SGP4
- #Performance
- Optimized SGP4 propagation in Zig achieves 11-13M propagations per second, making it the fastest general-purpose implementation.
- SIMD implementation in Zig is straightforward with built-in support, avoiding the complexity typically associated with SIMD programming.
- Three propagation modes were developed: Time Batched, Satellite Batched, and Constellation Mode, each optimized for different use cases.
- A polynomial approximation was used for atan2 in the Kepler solver, maintaining accuracy within SGP4's limits while enabling SIMD.
- Struct of Arrays (SoA) layout was employed for multi-satellite processing, improving cache efficiency and performance.
- Benchmarks show Zig's implementation outperforming Rust's sgp4 crate and Python's python-sgp4, especially in time-batched workloads.
- heyoka.py is faster for batch-processing many satellites simultaneously but requires more setup and dependencies.
- A live demo visualizes the entire active satellite catalog (~13,000 satellites) across a full day in about 3.3 seconds.
- Future work includes adding SDP4 for deep space objects and multithreading to further improve performance.