• 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.

zeress

Retired CK2+ Dev
70 Badges
Mar 4, 2012
2.359
650
  • Surviving Mars
  • PDXCon 2017 Awards Winner
  • Hearts of Iron IV: Death or Dishonor
  • Hearts of Iron IV: Expansion Pass
Hey all,

As you've undoubtedly noticed ever since JD CK2+ has been much slower and now is once again back to old form in terms of speed. All of this can be boiled down to one specific issue: Huge complexity in only the Silk Road.

What took so long to notice?

This is a simple question to answer. We were looking at too broad of a stroke of a reason what was causing the slowdowns. We looked at events in-general, trade in-general and so on. It wasn't until recently that we tried to pick apart things at a more granular level. It was there that we identified that only the Silk Road was causing a very large uptick in performance cost.

Why only the Silk Road?

A screen shot of before and after will help illustrate my example.

Screenshot 2018-03-18 11.57.27.jpg


Fig. 1 Before and After

As you can see in Fig. 1, there are less sub-parts of the silk road in the Middle East. That by itself however wouldn't actually be good enough; In fact that specific point does not have much of an impact by itself on the performance. What was a bigger issue are parts that feed into other parts increasing the code complexity of the route. So what I did was trim the fat.

Does route Homs -> Antioch need to exist, if both Homs and Antioch already have paths connecting them? While this part of the Silk Road certainly existed historically, it also added a footprint on the performance. Each one of these footprints seems to have exponentially increased the cost for each iteration of such a path in the chain, leading to the performance loss we had.

Don't other trade routes have this issue?

It is true that other trade routes in the mod have similar issues however the big difference is that they have far less of them total. In a future build a few of these will also be snipped in other routes to gain some marginal speed improvements and to allow the silk road to gain a few more paths as a trade off.

2.jpg

Fig. 2

As you can see in this fig. 2 once we started to compare other routes it became obviously clear that while other routes caused a speed loss that was deemed acceptable, the Silk Road itself was the main culprit in the speed loss.

Why was this only a problem with JD?

Previously routes were binary, they were on or off, with no gradients. As such I had designed those routes with many side paths that feed into each other so that only sections would ever be turned off unless several key points were strangled.

With JD however trade routes became much more fluid, where-in partial blockages could happen. This is a much better system design wise but clashed heavily with our old design assumptions. Now all those side routes and such that were previously needed became a huge burden onto the engine.

Trade Routes Moving Forward

In the future there likely be various, albeit smaller, adjustments to the trade routes now that we better understand the performance impact specific adjustments can have on the engine. It is unlikely that we will be adding much, if any, joined sections of routes opting instead for more 'dead ends'. That doesn't mean that loops won't exist, just that they'll be avoided

Cheers and Happy Gaming,
- Z
 
As far as I understood, the reason there are so many redundant routes was because they wanted to limit the ability of war in a few specific provinces to completely cut off the Silk Road. While I can appreciate the idea of trying to optimize performance, doesn't this just negate the point of the change in the first place? Are there other ways to compensate for the problem of bottle-necking the silk-road that don't sacrifice so much performance?
 
As far as I understood, the reason there are so many redundant routes was because they wanted to limit the ability of war in a few specific provinces to completely cut off the Silk Road. While I can appreciate the idea of trying to optimize performance, doesn't this just negate the point of the change in the first place? Are there other ways to compensate for the problem of bottle-necking the silk-road that don't sacrifice so much performance?
Typically speaking, features should never get in the way of performance.
 
I don't think silk-route is bottle-necked. It's still fairly wider and bigger than vanilla.
We'll probably continue to make it better. Now, at least, we have a stable benchmark for it.
 
Silk Roads feel really weak now (2% - 10%) perhaps a buff would go with this well?

The Silk Road will be adjusted in the next minor patch to make in inline with previous percentages, but if you are talking about fluctuations those are more or less a direct result of less paths in general.

Right, which is why I asked if there was an alternative....

The alternative is to trim other routes to benefit the Silk Road. I've made non-silk road ones a tiny bit leaner allowing for another loop in a future build but even that had a very small, but acceptable, speed loss so it actually is incredibly difficult to do much more there.