• 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:
While I am on a bad laptop
- Intel Core i3 with 2.00GHz
- 4GB of installed memory (RAM)
- 64-Bit operating system

I can run the game. The start up time is usually about 5 minutes and while it's a pain, I have a bigger problem.
When I click on single player and then go back to the menu, the whole game closes
(Message says Graphics Card Failed) and restarts (another 4-5 minutes). I assume this is just me but I don't know.

Make sure your laptop video card drivers are actually up to date. I had a lot of that on an old laptop I brought on vacation over Christmas and it was that (especially dxdraw errors). The other problem could be your video card actually running out of memory as its shared with system memory and its just crashes out since no memory available. 4 Gigs just isnt a lot now a days.

As for the reloading behavior, its supposed to unload then reload everything like at game start up.
 
Merci, @MatRopert , for this great and entertaining dev diary. Gives us lots of hopes especially to us in the M&T corner... :cool:

I don't recall a problem like this. Did you make a bug report?
Today's crash dumps are already pretty telling on what went wrong.
The tool itself will help for those edge cases where your game crashes but we can't find a reproducible way to trigger it.
Let the M&T mod turn on one of your computers for a while ? :D
 
@DDRJake - Might as well ask this here. and maybe it gets an answer. but. will you guys ever make a hotfix to at minimum fix the AI's religious conversion issues any time soon. or is this a case of "Working as intended" where Austria sits at 0% Religious unity due to protestant centers of reformations?
 
Interesting, so what does that mean for this mod, released some days ago: https://steamcommunity.com/sharedfiles/filedetails/?id=1702462029
"Gain a 5% - 15% performance increase without any loss of functionality or gameplay features."

I know, this isn't EU IV, but the 5%~15% sound phenomically high in comparision to your provided numbers.
While the mod states "no loss of functionality or gameplay" it does say the following down the line:
"The major issue with targeted decisions is that they need to check every country to see if it can be a target. New features allow to limit which countries are checked, which results in major performance boosts."

Without checking gameplay outcomes it is hard to say if this is the case.
 
I understand the original reason for forcing a full restart of the game due to changing meta-data through various forms.

What I would really like to have is a button after clicking new-game to exit fully to desktop and not restart EU4.

For example, If I am just browsing mini-map and changed my mind to not play right now. My currently ONLY option, for a good while now, is to alt+tab and kill EU 4's process.

Alt+F4 is your friend, works flawlessly and is instant
 
TLDR; Please stop adding in pointless tags, what is the feasibility of a “remove New World Tag” option in settings?

Hello,

I have long been frustrated with late game lag (and early game lag on my old pc.) It seems already established that the game could do with just a tiny bit of ... “streamlining?” .. increased efficiency?... less lag basically: as, that seems to be the focus of your upcoming free update and obviously the most recent dev diary (which was good). You have proposed a number of solutions to try and speed up game performance and whilst all admirable, they seem to have all come with caveats that they won’t actually translate into less lag (32-64bit sticks out here) and yes I know less lag is not your stated objective but, as already stated, it does seem to me that is the clear implied aim of the upcoming tech debt fix.

Now, the recent dev diary pointed out that more tags put a tremendous amount of strain on the end of month calculations the game has to make and this is indeed where I experience most lag. I’m sure others have similar experiences. Therefore; would it not make sense to stop adding in tags that serve no purpose other than to get steamrolled by European AI or the player. I’m talking of course about new world, and African tags (and possibly also Malaysian/Indonesian).

And what would you think about removing those already in the game? ****wait wait wait **** Now in and of itself this is clearly a ludicrous suggestion and I don’t blame you for clicking dislike but hear me out. Make it optional.

Content can already be cut off by the options in the settings screen (chance of advanced nations in RNW). Would it be possible, paradox, for you guys to add in a little switch that removes the New World tags (possible also African and Indonesian natives as well) allowing players who have absolutely no in game relationship to, or benefit from, said tags being in the game.

I know this obviously won’t happen, but please spare a moment to think about the comeplete useleness of having any native amwericna tags when all they do is get steam rolled. Well what about player agency! What if I want to play as them! What about all the hard work devs put in developing flavor for these nations! I hear you cry. It’s optional. You want to do a world domination as Cree? Or conquer Europe as Luba? Go right ahead this change will not affect you in the slightest or nullify the great work devs have done to the flaour of these nations.
What it will do however, is allow those of us who prioritize game performance over TAG that don’t amount to anything to scrape away at all of the resources used by those tags.

Anyway. What d’y’all think?

Edit:If you disagree, lemme know why, be interesting to know
 
Well, you picked up a micromanagement topic and said straightforward that it's tidious, clicking intensive and generally speaking slows down the pace of game. I completly agree with that, hoping for incoming expansion giving more automation to players with probably use of macro builder - like we have already with diplomats. Auto-building, auto-colonization, etc.. Or at least have ability to queue up, so we can set it once and forget for a while.
 
TLDR; Please stop adding in pointless tags, what is the feasibility of a “remove New World Tag” option in settings?

Hello,

I have long been frustrated with late game lag (and early game lag on my old pc.) It seems already established that the game could do with just a tiny bit of ... “streamlining?” .. increased efficiency?... less lag basically: as, that seems to be the focus of your upcoming free update and obviously the most recent dev diary (which was good). You have proposed a number of solutions to try and speed up game performance and whilst all admirable, they seem to have all come with caveats that they won’t actually translate into less lag (32-64bit sticks out here) and yes I know less lag is not your stated objective but, as already stated, it does seem to me that is the clear implied aim of the upcoming tech debt fix.

Now, the recent dev diary pointed out that more tags put a tremendous amount of strain on the end of month calculations the game has to make and this is indeed where I experience most lag. I’m sure others have similar experiences. Therefore; would it not make sense to stop adding in tags that serve no purpose other than to get steamrolled by European AI or the player. I’m talking of course about new world, and African tags (and possibly also Malaysian/Indonesian).

And what would you think about removing those already in the game? ****wait wait wait **** Now in and of itself this is clearly a ludicrous suggestion and I don’t blame you for clicking dislike but hear me out. Make it optional.

Content can already be cut off by the options in the settings screen (chance of advanced nations in RNW). Would it be possible, paradox, for you guys to add in a little switch that removes the New World tags (possible also African and Indonesian natives as well) allowing players who have absolutely no in game relationship to, or benefit from, said tags being in the game.

I know this obviously won’t happen, but please spare a moment to think about the comeplete useleness of having any native amwericna tags when all they do is get steam rolled. Well what about player agency! What if I want to play as them! What about all the hard work devs put in developing flavor for these nations! I hear you cry. It’s optional. You want to do a world domination as Cree? Or conquer Europe as Luba? Go right ahead this change will not affect you in the slightest or nullify the great work devs have done to the flaour of these nations.
What it will do however, is allow those of us who prioritize game performance over TAG that don’t amount to anything to scrape away at all of the resources used by those tags.

Anyway. What d’y’all think?

Edit:If you disagree, lemme know why, be interesting to know
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.
 
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.

Ah ha! I knew it! 666 heir being regularly slain by the beast is actually a bug!

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.

Finally I get where all these threads complaining about EU4 restarting when you exit a game come from. I didn't know the heathens had this performance issue.
 
Last edited:
Merci, @MatRopert , for this great and entertaining dev diary. Gives us lots of hopes especially to us in the M&T corner... :cool:

Let the M&T mod turn on one of your computers for a while ? :D
That's not hard enough - discover world, switch to trade map mode, make some additional modifiers visible, zoom out and scroll map a bit. )
 
Let's talk about the objectively most important question raised by this dev diary:
finally settle which of the Burgundian or Bordelaise tradition of winemaking is the best.
Romanée-Conti vs Pomerol intensifies...
 
Last edited:
Did a quick search and I couldn't find a thread on bug reports forum.

To give some background information, we fixed a bug on this for 1.17. The UI used to always say there was gonna be a battle, even if there wasn't. This was fixed so that the UI would use the same calculations as the game whether there would be a battle or not.
If I remember/understood it correctly, it used to decide if there should be a battle or not based on the tags. Not the index of the tag, but alphabetical order.

After initial testing on it now I could at first not reproduce your bug, but after some additional testing I found something that might be plausible (but I don't fully know until a programmer confirms it):
The game decides if there should be a battle or not, based on index of tags
The UI says if there should be a battle or not, based on the alphabetical order of tags

If this is the case, something either changed or broke since that patch (or it never worked properly).

What I am trying to say, if you ever have bugs, even if they are super obvious to you, please please please make a thread on the bug reports forum and attach saves.

I knew about this bug, and I did ask about its status in Quick Questions, Quick Answers quite recently. I though it was well known, many people answered so it kept me in my assumption. I simply thought that for some reason it was decided that it was not to be fixed.

I remember I had so much butthurt when I was playing Mzab (a later tag) against Portugal and Spain (early ones, so higher in the list?), trying to outmanoeuvre them outnumbered in North-West mountains of Africa, which required me to try to squeeze my armies within particular dates, without battle happening, and quite often battles happened without Battle Indicator, and vice versa, but I can't provide any save game now.

Would a save after the battle happen be enough, or you would have to have a save from before that battle? I usually play Ironman, so that would be hard(er) to achieve.
 
I knew about this bug, and I did ask about its status in Quick Questions, Quick Answers quite recently. I though it was well known, many people answered so it kept me in my assumption. I simply thought that for some reason it was decided that it was not to be fixed.

I remember I had so much butthurt when I was playing Mzab (a later tag) against Portugal and Spain (early ones, so higher in the list?), trying to outmanoeuvre them outnumbered in North-West mountains of Africa, which required me to try to squeeze my armies within particular dates, without battle happening, and quite often battles happened without Battle Indicator, and vice versa, but I can't provide any save game now.

Would a save after the battle happen be enough, or you would have to have a save from before that battle? I usually play Ironman, so that would be hard(er) to achieve.

Usually, saves before or during an issue is happening helps way more than a save after it has already happened. Understandably, it's very hard to have saves from before an issue happens and saves after is better than nothing. For this particular issue, I now have a save from when it is happening. :)
 
Ι am not a programmer, so this might be a stupid question:

Wouldn't it be possible to make it be multithreaded for everything in single player and keep the current form of single threading results that need to be the same for everyone in multiplayer to avoid desynchs?

That way SP where most people play on speed 4 or 5 is faster and Mp where most play speed 2 or 3 is same as now, but it doesn't matter a lot.

This is something I'm studying right now in the university so I'll try to explain some issues that arise with multithreading (not sure were to begin explaining though :p).

First of all there is the problem of shared variables between threads. This can cause a problem known as "race condition" which is when two different threads access the same variable at the same time and do a computation with it. And because you can't control which thread does this first it may happen that if you have x = 1 and thread A tries to increment its value in 4 at the same time that thread B wants to, also, increment the value in 5. Imagine that A goes first, so we would have x = 5 but as B had accesed the previous value of x, that is x = 1 instead of the updated value when B finishes we would have x = 6 instead of x = 12 as we should hadn't the race condition happened.

This is solved implementing mechanisms that allow only one thread to access a shared variable at a time however this creates a different problem called deadlock.
Deadlocks occur when several threads can't access a resource (a variable for example) they need and then the execution of the program may stop.
This may happen for example when Thread A needs Resource2 that is being used by Thead B whilst Thread B needs Resource1 that is being used by ThreadA.
There are also mechanisms to prevent deadlocks from happening but they can be either difficult to implement or even hamper performance.

In addition to all of this, as @MatRopert said there are things that can't be multithreaded, and to implement a multithreaded version the game for SP and a singlethreaded version for MP would probably be like making the game twice or two different versions of the game, one for SP and another one for MP.

To conclude, multithreading is great but the problems that come with it may be very costly to solve. Not everything can be multihreaded and I don't think that what you propose, though well intended, is feasible to implement.

I hope this explanation helped ^^
 
Also, the game already uses multithreading. The dev mentioned wanting to optimize its use of multithreading, but some things just need to be calculated in sequence either because the second calculation needs the result of the first calculation or as explained above because they both change the same variable. So, it's not as if EU4 where single-threading right now, they're just thinking of how they can use multi-threading more than they already do.