r/StarFrame • u/zontak93 • 4d ago
Devlog #10 - Performance Optimisation
Hello everyone,
As I kept adding new devices and features to StarFrame, I noticed the game was getting slower. I decided to spend some time optimising what I already had and start profiling the game to see where the time was actually going. To be honest, I’m still new to Rust and Bevy, and figuring out what the profiler was telling me took a while :D
One of the first things I looked at was ship physics, especially collisions with the voxel terrain. The ground is made up of a lot of triangles, and most of it stays the same while you’re flying around. I changed how I handle terrain collision geometry so the physics engine can reuse it when the terrain hasn’t changed. In the terrain tests I ran, that reduced the time spent on physics by around 40%.
I also improved how the game checks for collisions between ships. Before, ships within a fairly wide radius would trigger more detailed checks of their relative movement. Now I can rule out more pairs early and save the expensive calculations for ships that are close enough and moving in a way that could actually bring them into contact. That still gives the physics engine time to catch a collision before it happens.
Another issue was the planet itself. The planet is always moving, so even a ship parked on the surface could end up doing extra work just to stay in the same place relative to the ground. I changed that so objects resting on the planet can move with it. They still react when something actually moves them. Together, these changes made a big difference to server performance in the scenes I tested.
I also found some waste in the UI. For example, devices show live readings in their configuration panels, and I was updating UI elements even when you couldn’t see them. Now only the visible panels are mounted in the UI tree and updated. That helped the client’s FPS, especially in busier scenes.
On the networking side, I made some changes to reduce traffic and ran a local load test with 64 connected clients. All 64 synced, and the server met every tick deadline during the measured run. I also tried 100 clients. They all connected, but the server missed about one in six tick deadlines. So 64 is looking like a reasonable target, and I still want to see how it holds up with real players over the internet.
In the attached video you can see 100 ships in the same world, some flying and some stationary. Once the fleet settled, the server averaged around 60 ticks per second. I can still see occasional drops, and loading a big fleet can cause a noticeable hitch on the client. Profiling that hitch showed the client spending time checking ship connections and building the scene, so I have a much better idea of where to look next.
There’s still work to do, but it feels good to be able to measure the problems instead of guessing. This is only the beginning of the optimisation work, and I’ll keep coming back to it as the game grows :)
1
u/mediocrobot 21h ago
You mentioned that things resting on the planet just move with the planet. What about, say, a hot air balloon hovering above it? Does the ground move beneath that?