Jump to content

Possible Performance Optimization


Recommended Posts

Would it be helpful if when the game is paused or the ai is not doing a lot or when it is early on in the game, that it planned the next commands or tasks that it would execute (where to build, etc.), and store it in the ram, then it checks if that command would still work when the time comes to execute, and if so, it does it. The idea is to take some strain of the cpu when you are in a more cpu heavy part of the game with lot of units/structures, by calculating certain things when you aren't doing much. Now, if it is storing it in the ram, and you need more ram for the current stuff, it could just delete the current instructions, or like memory swapping, save it to the disk. I don't even know if it would help, or if it would make it worse.:shrug: (sorry if this doesn't make sense :)) If you are confused, just say so, and I can try to explain it better

Link to comment
Share on other sites

I was thinking of how an operating system uses extra ram to speed stuff up; "unused RAM is wasted RAM". I was wondering if that could apply to 0ad somehow 

Link to comment
Share on other sites

This won't work for 0AD. The main issue late-game is CPU lag from live pathfinding and unit checks, not a lack of RAM. Precalculating AI plans early on wastes CPU cycles because as soon as a human player moves a single unit, the AI's precomputed plan is invalidated and has to be thrown out anyway. Disk swapping AI instructions would also cause massive frame stuttering.

Link to comment
Share on other sites

1 minute ago, Genava55 said:

This won't work for 0AD. The main issue late-game is CPU lag from live pathfinding and unit checks, not a lack of RAM. Precalculating AI plans early on wastes CPU cycles because as soon as a human player moves a single unit, the AI's precomputed plan is invalidated and has to be thrown out anyway. Disk swapping AI instructions would also cause massive frame stuttering.

The purpose was to free cpu space, not ram

Link to comment
Share on other sites

2 minutes ago, Asher said:

The purpose was to free cpu space, not ram

Still, precalculating AI decisions early on won't work. Game state changes so fast that plans become completely invalid beyond just a few seconds into the future. That early precomputation does zero to relieve late-game CPU strain, in fact, it does the exact opposite. Constant re-planning wastes processing cycles, massively complexifies the codebase, and drastically increases the risk of CPU throttling right when performance matters most.

Link to comment
Share on other sites

2 minutes ago, Genava55 said:

Still, precalculating AI decisions early on won't work. Game state changes so fast that plans become completely invalid beyond just a few seconds into the future. That early precomputation does zero to relieve late-game CPU strain, in fact, it does the exact opposite. Constant re-planning wastes processing cycles, massively complexifies the codebase, and drastically increases the risk of CPU throttling right when performance matters most.

ok

Link to comment
Share on other sites

Pathfinding is not actually as performance expensive as one would think. The individual pathfinding requests each turn can be (and are) nicely computed in parallel by the engine, so on machines with decent hardware concurrency they finish surprisingly fast. The render submission process and rendering itself are a much more perfomance-constraining factor.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...