logoalt Hacker News

I Made Zig Compute 33M Satellite Positions in 3 Seconds. No GPU Required

134 pointsby signa11today at 9:51 AM17 commentsview on HN

Comments

lbeckman314today at 6:19 PM

Beautiful visualization at https://attron.github.io/astroz-demo! (~160 MB transfer)

My (very amateur) belief is that we're in a quiet golden age of cool space viz/tools, for example:

- https://www.asterank.com/3d

- https://dmytry.github.io/space/

- https://www.tng-project.org/explore/3d

- https://github.com/da-luce/astroterm

- https://ssd.jpl.nasa.gov/tools

Feels like the halcyon techno-optimism from TOS + TNG!

tylermwtoday at 3:22 PM

Nice results! SIMD can be a pain, good to know Zig makes it easy.

However, note that the plot under "Native SIMD Throughput Comparison" is extremely misleading: for an accurate proportional comparison between bar charts, you should start the y-axis at zero. The way the data are presented makes it look like a 10-100x gain, rather than the actual 2x improvement.

show 2 replies
notthemessiahtoday at 9:06 PM

This compares it to Python and Rust implementations, I wonder how it compares to Julia's SatelliteToolbox.jl? Julia also compiles to LLVM and has macros for explicit SIMD.

https://github.com/JuliaSpace/SatelliteToolbox.jl

exitbtoday at 5:05 PM

Is that solving the right problem? The algorithm can give reasonably accurate positions at arbitrary points in future, but you don’t need to run it over and over if you need positions every second. You can generate keyframes and interpolate the positions between, as the short term orbital movements are rather trivial.

show 1 reply
ww520today at 9:06 PM

Nice to have a huge speed up. Kudos for applying the right tools and right approaches to get it done. I especially like your explanation of how to utilize SIMD in Zig. Learned something today.

philipallstartoday at 3:14 PM

I've never seen SIMD code before, and this is quite a nice little intro into that and Zig.

dfajgljsldkjagtoday at 3:31 PM

It is funny how we often assume we need a graphics card for these kinds of calculations when a standard processor is actually plenty fast. The specific changes to the memory layout seemed to make the biggest difference here by allowing the hardware to actually use its vector capabilities.

show 2 replies
ginkotoday at 5:11 PM

There's one example given where either the result of a simple or complex calculation is picked depending on eccentricity mentioning it's faster to just always calculate both and picking with a mask.

If you calculate both, wouldn't it be even faster to just always do the complex calculation? (presumably that's more precise?)

show 3 replies
androiddrewtoday at 4:33 PM

You tell that language what to do!