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

EU4 - Development Diary - 9th of April 2019

Bonjour everyone! It is I, Le French Paradox and I will be your host for this Dev Diary.

Today we will talk about Tech Debt. As @DDRJake has been saying, tech debt has been an important focus for the EU4 team since the release of 1.28.3, the latest support patch we did for the Spain update. While our designers are thinking very hard about the yet-to-be-announced big expansion that is to come, we programmers have been busy tidying up the EU4 codebase.

tidying up.jpg

Microsoft should team up with Netflix, I would watch the hell out of this show

Jokes aside, we keep talking about Tech Debt but realize it might be a bit confusing, especially for our non-programming crowd.

While EU4 was announced at GamesCon 2012, the actual development started a year before, which makes the code 8 years old. And of course, the team at the time didn't reinvent everything, bits were pulled from EU3, some of which are still in use today. I'll let you speculate which is which in the comments.

As I'm sure you all know, technology is a rapidly evolving thing, and software engineering is no exception. In 10 years the development practices have evolved, both because the industry keeps learning and inventing new ways to solve problems, and because the ecosystem (the hardware and software that runs our games) also changes.

10 years ago, SSDs were not that widespread, 1080p was pretty new, DirectX 10 was all the rage in previews and most people were so hostile to Windows Vista that they kept running XP in 32 bits.
That is not to say that EU4 was using only stuff from the late 2000s or early 2010s until now. Over time our engineers have done their best to keep the game up to date, but some stuff inevitably slips through the cracks. It's the accumulation of all this aging stuff that we call tech debt(*).

Here's a few examples of those things that we have tackled so far.

64 bits
As the BattlePope already explained in a past DD, 32 bits was a reasonable choice when EU4 development started, but today 64 bits in the norm.
With that done EU4 will keep running with the next update of MacOS (which removes 32 bit compatibility altogether) and also be able to use more RAM. While there are no immediate plans to increase the memory usage of the game significantly, mods that add a lot of provinces and tags should be able to break the previous ceiling.

Rendering
It is no secret that our games do not use cutting edge graphics. True to its board game heritage, Europa Universalis is mostly about showing a world map with some cool dudes (and elephants) fighting on top of it. Yet if you take a look at the Imperator preview, you will see that our graphics experts have learnt a trick or two since EU4's release.

2xnk41.jpg


While Boromir is (was?) right, we still managed to replicate some of the improvements they have made. The main one is that the colorizing of the provinces on the map is now done mostly on the GPU, while in the past it used to consume precious CPU cycles to display whatever horrible experiment in bordergore your game was about.

capture.PNG

Let's play 7 differences, can you spot what changed from the current release in this beta screenshot?

Crash reporter
Our game never crashes, it just tactically exits. Yet when it happens, we want to know all about it. It helps our QA to reproduce the issue and our programmers to isolate the piece of code responsible and fix it.
Since EU4's release our engine team has made a new and improved crash reporter that brings us more data and help find problems faster. First of all, it now works on Linux and MacOS, meaning we will be able to investigate issues on those platforms much easier. Secondly, it allows us to add some metadata to the dump, such as the current year, the list of enabled mods or how many 6/6/6 heirs died to a hunting accident, helping us understand what triggered the issue.

Startup time
Improving the loading time of the game is something we always want to do. While we can't really apply the best fix to the issue (discontinue Windows support, the game just starts so much faster on Linux and MacOS, trust me), we managed to find some things we could do.
The most notable one was the upgrade of PhysFS, a 3rd party software that a lot of videogames use to load all resources (files on disk, mods, DLCs...). While still far from Unix performance, it should shave off a couple seconds from the startup time on Windows.

capture.PNG

Experienced Byzantium players recommend playing on Linux or Mac due to the very fast restart time

General performance
The speed of the game is, of course, always a concern. Every night, we run a couple games on benchmark machines and always make sure that the averages are below a certain value (80ms per in-game day is our current high threshold).
While you may think that performance would improve over time (due to new hardware for example), in practice the average usually go up during the development phase of a new expansion, and is then worked upon to bring it back to acceptable values.
Contrary to popular thought, adding new features in the game is not the only (or even main) source of performance regression. In fact, one big factor is simply the addition of tags and provinces.
Consider this: for every two countries in the game, a bunch of stuff needs to be computed each in-game day (relations, AI attitude...). For every two provinces in the game, the game has to know the way from A to B (what we call pathfinding). This is known as a quadratic problem. For those who don't favor math, it means that for X provinces, the problem complexity is X squared. Doubling the number of provinces does not double the number of computations needed, it quadruples it. Over the years, part of our job has been to allow EU4 to grow from around 2000 provinces to more than 4000 provinces.
Keep in mind though that in software engineering an optimization that makes something 0.1% faster is considered pretty good, 1% excellent and 10% probably means you introduced a serious bug (or fixed a very serious one). How do we manage to improve anything with those numbers? Simple: all those add up in the end.

That's all for today! Should you like to know more meaty details of the tech stuff, you can check-out my blog where I get into more practical details about development practices.

Next week we should return to a more classic Dev Diary by our designers, unless you can help me convince Jake to revamp the wine trade good to include grape kinds and soils and finally settle which of the Burgundian or Bordelaise tradition of winemaking is the best.

(*) It's a bit more complicated than that but should be enough for the sake of this diary
 
Last edited:
Guess what, I disagree. There is something off in your reasoning: more tags, more late game lag. Late in the game, the amount of tags is drastically lower as many of the minors have been eaten (take the HRE or the New World). I don't claim that the game no longer checks decisions etc for them, but it should be logical that the game no longer performs checks for dead nations. Having more minors gives you also more chances when playing as a minor. It would be a lot harder to expand as the Karaman when the other Anatolian minors + Aq Qoyunlu don't exist. The natives are a weird case though: they give the player the choice to play over there, they give the player the choice of which country they want (obviously the one with the prettiest flag) and give potential allies when the Europeans arrive.
Back on the topic of performance, I believe that the amount of provinces is the real killer. Take events/decisions that affect provinces. There are way more provinces than countries, and both have events/decisions that affect them. Not only that, but more provinces gives more distance calculations, both for moving armies as the AI. More provinces gives more manpower and more force limit, so a lot more armies are present on the map; later in the game, many of the previously uncolonized provinces are now also producing troops. More provinces gives the AI more places where it trains troops from (and since it loves spamming 1K armies, we get lag spikes since suddenly the world contains +10% more moving armies). This is IMO the reason why late-game lag exists: it's more about the multitude and the magnitute of provinces/armies than about the multitude of tags. Lag due to tags is something that can easily be greatly minimized (for example by ordering the triggers). Lag due to provinces is a totally different story.

As last thing: try to find a mod that fills in the current map with fewer nations. I'm rather sure I recently saw one on the workshop. Else, maybe try to propose one or even make one yourself? It's not a very difficult modification.

Thank you for taking the time to reply. Agree almost totally. I perhaps shouldn’t have mentioned late game lag in the same post as your quite right, it doesn’t stand up to logical reasoning. However I think it is a valid observeration/assertion that, crudely, more tags = more lag. Would never suggest taking away old world tags for exactly that reason. What’s the point of natives as allies are as a colonizer? Other than that agree.


Valid point and it’s made in this very dev diary as well.

I am planning on doing that actually, watch this space :)

Cheers
 
That's not hard enough - discover world, switch to trade map mode, make some additional modifiers visible, zoom out and scroll map a bit. )
Got to turn up the heat slowly... or they'll get scared... :D
 
Is one of those benchmarking machines running on a Ryzen CPU? because a significant number of people already have them, all my friends that have upgraded their machines have bought Ryzen 1600's and then 2600's.
 
Ok, I know that dev diaries aren't meant to be suggestion places but:
Couldn't you create, in some safe places, pre scripted paths between some regions and incorporate with the ai and mechanics, for example:
The Castilian AI has some troops in Seville when it's declared war by France, so it have to move its troops to Navarre, instead of calculating for every possible province in Iberia it moves to one of the provinces of a predefined "road" connecting Lower Andalucia and Vasconia areas (that can also be used to reach nearby provinces) you could tie infrastructure development and AI strategy as it could pull some resources to upgrade such road and block enemies from using it
 
Let's talk about the objectively most important question raised by this dev diary:

Romanée-Conti vs Pomerol intensifies...
The huge question is "Are Bordeaux winemakers right in mixing grapes differently every year depending on harvest to get a nice blend or are they alchemists who have forsaken the art?"
 
However I think it is a valid observeration/assertion that, crudely, more tags = more lag.
It's interesting that you bring that up as lag.
At the risk of being pedantic, it's best to distinguish some things in that matter:
  • Lag is tied to latency (ping) and usually due to either slow network connection, the server being overloaded or your machine being too slow to keep up with the host speed. Symptoms are usually a delay between a player input and an actual effect in the game. It's most commonly seen in shooters when you shoot some dude in the face, but instead of the expected result (said dude dying of bullet wound to the face), your target moves and your bullet hits whatever was behind him. Basically what your game shows is a couple in-game time units behind what it actually is. It is tied to the nature of multiplayer games and will not happen in singleplayer. Ideally you should play at a speed in which all clients can keep up with the host without ever needing to slow down or pause to allow them to catch up.
  • Stuttering (french: "ça rame grave") happens when your computer is too slow to render the game graphics. It is usually synonymous with frame drops, like rendering a video with a low FPS count. It is normally due to your GPU being too slow for the game (or we did something terribly wrong :) ).
  • EU4 employs some tricks to keep your framerate stable when you CPU can't catch up with the game speed, your graphics might still look fine but the daily ticks pass slowly and your actions take some time to be processed. This is an issue tied to the many computations done every ingame day. It is more noticeable later in the game. Pausing the game should make the problem disappear and allow you to give as many orders as you wish as fast as you can.
Lag is not something we can do much about, but the others we try to investigate.
The most important ones are when the game stutters, even paused. This shouldn't happen since the rendering of EU4 is cheap by modern standards. Sometimes we miss something (like a recent trade company alert performance bug) but it should always be fixable.
Daily tick getting slower is trickier because it's tied to the complexity I mentioned in the original post. As I mentioned we do make sure it stays below a reasonable average every patch. The biggest reason for this is AI, and the fact that almost every day each country needs to make decisions, and there are a lot of them and a lot of things they can potentially do. For fun you can use the 'ai' command in the console to turn it off (in SP non-ironman) and you should see a drastic difference in speed.

Hope this clears things up and helps you describe your issue(s) better.
 
Huh! Guess I can add "EU IV loads faster" to the list of reasons I use Linux. :) I thought it was just the SSD I was using. I finally get why people complain about the load times now...
 
Good diary that also is an eye opener on the other Paradox titles.

Think you might have persuaded more people to try Linux btw

I started dualbooting shortly after new years, when I installed Manjaro. Now, I honestly can't even remember the last time I booted into Windows. Granted, I've only been playing Paradox games and some CSGO (which also works great on Linux), but I haven't exactly felt like I've been missing out.

I'm now in the rather ironic situation that I game at home on Linux, and I work (as a developer) on a Windows machine (because stupid company enforces it).
 
It's interesting that you bring that up as lag.
At the risk of being pedantic, it's best to distinguish some things in that matter:
  • Lag is tied to latency (ping) and usually due to either slow network connection, the server being overloaded or your machine being too slow to keep up with the host speed. Symptoms are usually a delay between a player input and an actual effect in the game. It's most commonly seen in shooters when you shoot some dude in the face, but instead of the expected result (said dude dying of bullet wound to the face), your target moves and your bullet hits whatever was behind him. Basically what your game shows is a couple in-game time units behind what it actually is. It is tied to the nature of multiplayer games and will not happen in singleplayer. Ideally you should play at a speed in which all clients can keep up with the host without ever needing to slow down or pause to allow them to catch up.
  • Stuttering (french: "ça rame grave") happens when your computer is too slow to render the game graphics. It is usually synonymous with frame drops, like rendering a video with a low FPS count. It is normally due to your GPU being too slow for the game (or we did something terribly wrong :) ).
  • EU4 employs some tricks to keep your framerate stable when you CPU can't catch up with the game speed, your graphics might still look fine but the daily ticks pass slowly and your actions take some time to be processed. This is an issue tied to the many computations done every ingame day. It is more noticeable later in the game. Pausing the game should make the problem disappear and allow you to give as many orders as you wish as fast as you can.
Lag is not something we can do much about, but the others we try to investigate.
The most important ones are when the game stutters, even paused. This shouldn't happen since the rendering of EU4 is cheap by modern standards. Sometimes we miss something (like a recent trade company alert performance bug) but it should always be fixable.
Daily tick getting slower is trickier because it's tied to the complexity I mentioned in the original post. As I mentioned we do make sure it stays below a reasonable average every patch. The biggest reason for this is AI, and the fact that almost every day each country needs to make decisions, and there are a lot of them and a lot of things they can potentially do. For fun you can use the 'ai' command in the console to turn it off (in SP non-ironman) and you should see a drastic difference in speed.

Hope this clears things up and helps you describe your issue(s) better.

Merci monsieur, Je suis tre desolé, votre enterprise ces’t tre Bon! et vu et vu compains. Pardon moi pidgin Francais, je suis un roti de boeuf.

Si vous pardon mon anglais, that’s a really good point I do apologize I shouldn’t have used the word lag I was being lazy. The slow down of the daily tick is what I was referring to. I shall indeed try that for fun.

As ever thank you, and keep up the good work!
 
About the controlled crash to desktop done to reset checksum: If this was the reason this thing was done then the original “fix” would have been enough i.e. game greyeing out the multiplayer button once single player is clicked or a game has started. No lets make the more elegant solution of game crashing to desktop if you misclick single player before going to options, game crashing to desktop AND restarting (loooool) if you want to click on the back button on the map scree, while all you wanted to do was to to back and quit without restarting. Idk really how this thing has been allowed on a game where before it worked. My 2 cents are that the game has a memory problem and aint able to wipe for good the memory even in SP, its not just about checksum, there was an exploit couple years ago that made you change original grand campaign settings by just switching bookmarks before starting the game, and i think this is the issue that devs didnt manage to fix, not a checksum affecting 2% of player population of which 1.9% aready knew about the checksum issue anyways. Funny thing is that you can de facto change bookmarks anyways before starting the game so this horrible workaround is here to literally make people restart the game because a little part of the players pop can't close the game before re entering a multiplayer game (i repeat, a pop up informing about checksum change or greyeing out the MP button as it was in the original game would have been way more elegant and less neapolitan)

Also ui saying bullshit about truces expiring is well know if you play one (1) game, i’ve played a game with byz yesterday and the truce for my 2nd ottoman war (not the varna pregame truce) should expire at december according to the tooltip but when time comes it expires amost always in november, once at october, once the pop up came in in november but i was still truce breaking if i dowed in nov, once i wasnt, i mean full randomic, its like that the game has 3 different counters taking count of the same thing and none of them are synchronized, like popup msgs arent synced to the real truce checker, and the humiliate rival/conquest casus bellis arent synced aswell cause they always are spawned in a later date compared to the truce being gone. In this game it also happened that my truce with ottomans as byzantium lasted 1 month less than between them and the ally who helped me in the first war, albania xD

I got several backups of that game cause...well...byzantium... so if devs really need it its ok i can give it to them but i think its a bit absurd that they didn't notice it at all... its there in every game, maybe not for pre-game start truces but as soon as you peace out a war there is a chance that the truce after it will be bugged as hell XD
 
Last edited:
About the controlled crash to desktop done to reset checksum:
It wasn't just about multiplayer sync problems, though.

It was also about a steady stream of unreproducible crash bugs from SP players, that could happen an arbitrary amount of time into a campaign if that campaign had been "infected" by bouncing in and out of the lobby before starting.
 
It wasn't just about multiplayer sync problems, though.

It was also about a steady stream of unreproducible crash bugs from SP players, that could happen an arbitrary amount of time into a campaign if that campaign had been "infected" by bouncing in and out of the lobby before starting.

I believe some of those if not all came from SP players who did "weird" thing like changing the history bookmark before finally settle on who to play as or even loading a different save game, only to see unexpected behavior or game state. Or even outright changing the checksum without any mod installed which can block players from getting achievement or start ironman game. It is not just multiplayer only issue and it can affect SP on it's own as well.

If I remember right, EU 4 team tired a few things to try fix this only to break the game even more than it was before. At some point they just gave up and forced EU 4 to completely restart. EU 4 was build on top of EU 3 code and EU 3 was build on EU 2 code and clean code didn't exist back then. So I wouldn't be surprised if those bugs can be traced to ancient code that no one on EU 4 can understand or if they try to they would get a serious headache. In fact I recently read an article that one of the most bug-prone programming language is C++ and guess what EU 2 was build with? Yup you got it.

I wouldn't be surprise if you didn't remember that SP players were affected badly by this issue without touching a multiplayer lobby as it has been a long time since they implemented the hard restart. In fact you can look up some of my ancient post talking about this issue if you care to.
 
I believe some of those if not all came from SP players who did "weird" thing like changing the history bookmark before finally settle on who to play as or even loading a different save game, only to see unexpected behavior or game state.
Just entering the SP lobby and leaving it would corrupt the gamestate. (Moving back and forth between start dates made things worse, of course.)
 
  • Stuttering (french: "ça rame grave") happens when your computer is too slow to render the game graphics. It is usually synonymous with frame drops, like rendering a video with a low FPS count. It is normally due to your GPU being too slow for the game (or we did something terribly wrong :) ).
  • EU4 employs some tricks to keep your framerate stable when you CPU can't catch up with the game speed, your graphics might still look fine but the daily ticks pass slowly and your actions take some time to be processed. This is an issue tied to the many computations done every ingame day. It is more noticeable later in the game. Pausing the game should make the problem disappear and allow you to give as many orders as you wish as fast as you can.
Lag is not something we can do much about, but the others we try to investigate.
The most important ones are when the game stutters, even paused. This shouldn't happen since the rendering of EU4 is cheap by modern standards. Sometimes we miss something (like a recent trade company alert performance bug) but it should always be fixable.
Daily tick getting slower is trickier because it's tied to the complexity I mentioned in the original post. As I mentioned we do make sure it stays below a reasonable average every patch. The biggest reason for this is AI, and the fact that almost every day each country needs to make decisions, and there are a lot of them and a lot of things they can potentially do. For fun you can use the 'ai' command in the console to turn it off (in SP non-ironman) and you should see a drastic difference in speed.

Hope this clears things up and helps you describe your issue(s) better.

Purely out of curiosity (I'm no programmer) but I would have always thought that as the number of tags decreases going into the later game (in most scenarios) that the stutter found in the late game would be reduced since there's not as many calculations? I just find it a little galling when I get to the last 20 or so years of a game and it starts to grind to an almost halt and capped out a core on my i7 9700k.
 
Just entering the SP lobby and leaving it would corrupt the gamestate. (Moving back and forth between start dates made things worse, of course.)

OK I think I am lost. What do you meant by SP lobby? Exactly?

I take the lobby word as a place to gather together to talk or a chat room for players before they start a multiplayer. Similar to lobby room on the first floor of almost all hotel except just in digital form.

Are you using a different meaning of lobby that I am not aware of?
 
@grommile you can still move back and forth using bookmarks iirc, so de facto the “bug chance” in SP is almost the same as before, excluding the bugs you would get by playing a game and starting a new one in the same session, rest is the same as before for SP

@The_sherbet game engine takes in account also dead tags that could spawn from their core provinces. Idk if it rules them out once they cant be released anymore, but i think not