In the past, whenever I’ve talked about the efficiency of pathfinding, I’ve universally been speaking about CPU usage or “number of paths calculated per second” or something along those lines. This time, I’m talking about RAM efficiency — how much RAM is used, how it gets reused, and so on. We do a lot of pathfinding on a lot of threads for a lot of reasons, and that data can be absolutely enormous if we’re caching it for too long. Similarly, in the past, we’ve had major CPU load caused by not caching it enough.
What I’ve done at this point is kept the caching to the level of “this current slice of time for this thread,” whatever that means. Sometimes it means “this frame” when we’re talking about the UI. A lot more frequently, it means “this simulation step,” when it’s something for the simulation itself (aka, for 100ms). Even vastly more frequently, it means “this run of long-range-planning operation,” which is something that happens intermittently for each faction every few seconds and lasting for usually part of a second, but up to several seconds if need be.
The TLDR is that the amount of CPU computation should be roughly the same as before, but the RAM usage is reduced by around 300ish MB on midsize games with a fair number of factions in a slightly larger than average galaxy. It may also be a fix to yet another memory leak, but I can’t be certain. It is a solution to an annoying thread-contention issue that I still don’t understand the full nature of, but have decided to work around in this particular case by just making everything so much more efficient in the first place.
This build sees a number of other bugfixes, and more of SirLimbo’s AMU settings being implemented into the base game as options.
More to come soon.
Enjoy!