FPS smoothly degrades most of the time but occasionally this occurs

I threw together a little test project to do some limit testing. I’m getting FPS spikes which appear to be tick bottlenecking. The weird thing is sometimes the test can pump out 1500 actors and smoothly work its way down to 40 FPS. Other times I get what you are seeing here in this video. What would cause these inconsistencies?

Hey

It looks like you’re making too many or too heavy calculations every time the turrest shoot to determine who they should be shooting, and the video shows how the freezes decrease at the end when you have less turrets shooting.

Best theory, you’re overloading CPU and/or memory, so its normal that some times the FPS drop is smoother than others, depends on how saturated your PC is at the time of testing.

Find a way to reduce calculations to the minimum necessary and keep an eye on the PC resources.

I’d suggest converting the map find function in your blueprint library to an FRunnable thread task with workers.
You will offload the gameplay thread and not cause the game to stall.

Thank you so much for the quick reply. Hmm the calculation is as bare bones as I can get it. Grid indexes are structs with list of units inside. Units move grid index to grid index, if unit enters a turret’s outer grid index & turret isn’t already shooting then shoot. Other than converting all array & map hits to C++ I’m not sure how to optimize it further

Thank you so much for the quick reply. This sounds like a promising option - could you suggest any resources on what challenges this could introduce? The actual project I’m working on is going to be multiplayer. Will this introduce more inconsistencies for me to handle in the netcode?

You can offset heavy calculations to a separate thread and tell the game thread once it’s done.

A good example

No difference if it’s single or multiplayer (just make sure the server has an extra thread for calculations).

Call a function once the calculations end, you can either use the output directly on the server or multicast the result to clients