Stellaris Performance Analysis #2

  • We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.
Rather than pop searching for job every X, wouldn't it make more sense to have them only check for job when something happen to the planet (i.e. new building/district or pop growth and immigration). It's not like there's any reason to check if nothing changed since the last check, you could just tag a "all pop on planet look at job" function at the end of building production and pop growth and remove the constant checking entirely (or like keep it but only once every 5 year or something for planet that are set to not grow anymore in case there's some rare event that may changes things).

As far as wormhole/gateway, that's a lot harder but that's not new, does it affect performance more than before or is because the new pop mechanic is straining everything so much were only really noticing it now? Is there a significant difference in performance with and without L-gate (since that essentially double the number of gateway network, maybe the number of gateway doesn't really matter and it's just the presence of a network that cause a problem).

Otherwise it might be better to have the game treat these as regular hyperlane (i.e. every gateway system would have an hidden hyperlane to every system with a gateway), I don't think increasing the number of hyperlane in existence at the game setup as much of an effect on performance (at least I've never read anyone say that there game was slower cause they had high connectivity).
 
I guess that means I wont be running Glavius' AI mod anymore.

If you fear the potential added micro, opening higher strata jobs still suck lower strata pops from their jobs. It's just that if the jobs you opened left a worker job open, there won't be resorting of worker pops. It will be filled either when new pop finishes growing, or you close a job and then reopen it. Usually it's just a matter of closing/reopening a few clerk jobs when a little in red for some resource. Not a big deal and far worth the overall improvement.

I was as surprised as you..it actually does work. The only reason i tried it was b/c it was the only game i had that had crisis spawned and wanted to see if a mod fixed it.

It’s aint perfect...all planets have only city districts for example...and the pop counts/0 buildings present on all planets make any economy the AI has useless. But it loaded and ran.

Yeah, but there is no economy left to calculate for, at all, barring orbital mines. That's what I meant by cogs being loose. You can't know what's broken and what really nets you the perf gain in this case.
 
A way to fix the problem of pop calcs is the same way Glavius did. Make it so that ONLY new pops and unemployed pops check for jobs. Once they find one, make it so they have to be manyally taken off their job for them to check for a new job. That'd probably fix the performance issue with pop calcs.
 
There's a mod that removes "trade range" from trading hubs and adds a "trade range" of 1 to any outpost, thus eliminating the fact that the game supposedly reacalculates trade routes every day or month. People using that mod said that they did get a performance boost, albeit it wasn't the be-all-win-all solution. Has this been looked into?

I tried it, it did absolutely nothing for me on 2.2.3
 
A way to fix the problem of pop calcs is the same way Glavius did. Make it so that ONLY new pops and unemployed pops check for jobs. Once they find one, make it so they have to be manyally taken off their job for them to check for a new job. That'd probably fix the performance issue with pop calcs.

No, I have no idea why the notion of a pulling system is so appealing. Use push notifications. Every time a job opens up or closes, every time something happens that changes the local job situation, inform the interested parties (e.g. unemployed pops) of that event, then the pops can decide what to do. Pulling unnecessarily when nothing's changed is a waste of CPU time.

Yes, the system's a bit more complicated (not much), but it's also more automated and resource friendly.
 
No, I have no idea why the notion of a pulling system is so appealing. Use push notifications. Every time a job opens up or closes, every time something happens that changes the local job situation, inform the interested parties (e.g. unemployed pops) of that event, then the pops can decide what to do. Pulling unnecessarily when nothing's changed is a waste of CPU time.

Yes, the system's a bit more complicated (not much), but it's also more automated and resource friendly.
Especially considering that there is such a system in Stellaris even for modders to use: "on_action" that can trigger events when certain stuff happens. A bit strange that they seem to not having done the same for internal stuff...
 
It seems crazy! I don’t understand how anyone could’ve thought this new system would save on calcs. The old tile system was route simple. A tile was either occupied or unoccupied. Pop movement was confined to immigration. They never switched. The complaint was it eventually became a pain to min max your pops. But that was fixable.

Here? This new system is more expensive computationally while offering the player less control!

Sadly, a tile is not either occupied or unoccupied, it can get quite a bit more complex than that. The AI has to figure out what the tile's resources are, so the optimal building is build/upgraded. Then it needs to figure out which the optimal population for the tile is and how that affects other tiles. It essentially needs to calculate all the possible tile variants, then select the best one. Now, if your code doesn't have an explicit check if something changed, you'll need to recalculate this every tick. The new system can be more performant, if it's based on events - i.e. something happened, check if it affects the jobs and recalculate as necessary. The planetary infrastructure is quite a bit easier - you either have something or you don't, meaning it's fairly easy to represent with a decision tree.
 
Correlation with population numbers
The population and wars data has been extracted from collected saves. Plots have been updated, with the population plotted in orange against right axis. Wars plotted in purple against right axis (500 for 0 wars, increase of 500 for each war). Different session plots feature same scale for ease of comparison.

As recent sessions were about gestalts, let's start with them.

First, the gestalts-only game, which showed nice performance:
223-gestalt-detailed.png
The correlation between performance and population is clearly seen. The start of the war usually (but not always) results in a peak on the performance plot. Guess about population extinction in 2280 thus was not correct, performance was improved because all the wars were over.

Next, the gestalt-noholes game which showed worse performance:
223-gestalt-noholes-detailed.png
The same set of empires was spawned, but there were indeed a lot more wars and more population. The huge peak in 2350 correlates to start of another war between regular but rather large empires (Zaxxoan - Mictoran War of Humiliation). Doesn't look like absence of wormholes and gateways actually affected something. Making note about no trade and thus no calculations of trade routes via holes/gates and moving further.

New session gestalt-noholes-nomarauders was recorded to cross-check nomarauders session:
223-gestalt-noholes-nomarauders-detailed.png
It seems that presence or absence of marauders actually has very little effect. Performance in first 125 years is about the same, then it starts to differ due to population.

To finish with "marauders phenomena", let's look at nomarauders game, which showed really nice performance:
223-nomarauders-detailed.png
Apparently the "phenomena" was just low population. A nice example of drawing wrong conclusions from lack of information.

Let's return to wormholes and gateways and look at noholes:
223-noholes-detailed.png
There's a bit more strain in 2310s, apparently due to khan doing khan stuff. Other than that there is little difference between this and nomarauders, which again gives some doubts to wormholes or gateways having much of impact. To tell for sure if that is true or not, again, there needs to be a number of activated gateways/L-gates, to compare performance with, which is not yet traceable by parser.

There has been, however, manually checked one regular setup game to see if having gateways affected performance:
223-1-detailed.png
Loading game in year 2375 showed that gateways were already activated by several empires (and they had access to second gate) and there are no anomalies to see prior to this date. The plot actually looks much like any other gestalt one which as well makes one to doubt if trade calculations have any impact in latest beta.

That doesn't mean that there is no impact from wormholes\gateways\trade, maybe it's just not traced by this type of simulation. As mentioned in first issue, the performance of actual gameplay is way worse than one in observer node, so it might very well be that trade affects performance via, for example, UI updates. Before new beta rolls out it would be interesting to record some human_ai (but without observer) sessions to see if that's true or not.

Additionally, if I recall people were noticing drops of performance after construction of new gateways, maybe something fishy is happening with the way how they are handled.

Regular setup number two:
223-2-detailed.png

And number four (saves for setup three somehow got not copied from my simulation PC):
223-4-detailed.png

Again, this doesn't look much different from gestalt games. Performance is more or less dependent on population counts with occasional spikes when wars are declared/khan is on the rampage. There is, however, some strange jump at around 2360-2400 seen on most games. I do not have explanation for it yet, the quick glance at 223-1 saves rules out War in Heaven or L-gate opening scenarios. In most cases it is tied to start of the war, so could be just a lot of ships moving around.

And for the dessert, the nomigration game:
223-nomigration-detailed.png
A curious example of performance "lagging" behind pops count. This game had wormholes/gatewayas and trade, so, well, you get the idea.

Outcome
  • #pressXtoDoubt about performance being affected by trade. To be checked on actual gameplay
  • #pressXtoDoubt about performance being affected by existing wormholes\gateways. To be checked on actual gameplay and by constructing new gateways
  • Performance is heavily tied to population, optimization there should help all across the board
  • Fixing crisis purge looks like cheap and dirty way to get some improvements
 

Attachments

  • gestalt_and_extra_data_csv.7z
    1,2 MB · Views: 8
Last edited:
Curious that performance-pop dependency is apparent, but it's not linear. Looking at the data presented, I mean.
Also, these numbers are really good reference points. The game, in theory, could be played well beyond 2500. But in practical terms it's pointless. So the devs should aim at around 10k POPs for performance. Aim here being meaning for game to be able to handle this number at least reliably. Anything above that is nice, but in the overall situation not that relevant. But this number is really good indicator. Like, create a galaxy, spawn 100 POPs at 50 planets - and voila, you have very rough, but very simple and useful starting point for performance tests
 
No, I have no idea why the notion of a pulling system is so appealing. Use push notifications. Every time a job opens up or closes, every time something happens that changes the local job situation, inform the interested parties (e.g. unemployed pops) of that event, then the pops can decide what to do. Pulling unnecessarily when nothing's changed is a waste of CPU time.

Yes, the system's a bit more complicated (not much), but it's also more automated and resource friendly.

Especially considering that there is such a system in Stellaris even for modders to use: "on_action" that can trigger events when certain stuff happens. A bit strange that they seem to not having done the same for internal stuff...

This is something that always bugged me out. The game is entirely designed around events. Why actively check for things? Pop job checking not being event driven goes against the architecture. Just define a set of constraints triggering the check within a scope, and leave them alone the rest of the time.


One thing I did notice is that sometimes the game decides to randomly and suddenly refuse to go above 22fps on my rig, with hellish stuttering. That can be upon loading a save, clicking on a system to go in system view, random other unknown things... It is sometimes simultaneous with the giant models on galaxy view bug, and is solved by reloading another save. Granted I use a texture mod for planets that's rather heavy, but I'm wildly guessing it has to do with the link showed between render loop and game logic in this thread :
https://forum.paradoxplaza.com/foru...ellaris-a-quick-performance-analysis.1138327/
since the giant thingies bug is not new at all.
Maybe there's randomly triggered borked states of overall execution on top of the rest.

Additionally, if I recall people were noticing drops of performance after construction of new gateways, maybe something fishy is happening with the way how they are handled.

Regarding this specifically, and while there's a long time I didn't build gateways, I always see a drop in performance when getting a new system and hyperlane via precursor event. What I think about all this is that the game doesn't like at all messing with initial galaxy path layout.
 
Thanks for all the graphs, great work!

Have the devs said how often the pop job calculations are done? I agree with the other posters here that there is no point in calculating periodically. It should only be done when something changes on the planet.
 
Have the devs said how often the pop job calculations are done?

I can't confirm that to you, however Glavius said this 5 hours ago in the comment section of his mod regarding trade routes :
It calculates daily but I can't change it as its hard coded.
which again are a monthly thing (and could rely on events for changes to begin with :D).

I guess he is to be trusted and that pop jobs are certainly no different.
 
I'm wondering if there are other pop or economy related checks besides jobq that are done frequently.
1) Does anyone know how often the AI checks to build a building or district? As the number of colonized planets increase in the galaxy, I assume that could also cause a slowdown.
2) Ethics checks are only done once a year I think, so that shouldn't be much of an issue.
 
Last edited: