Closed RecursiveVision closed 3 years ago
Report on the forums:
The last attack for Capturing cities takes so much time and freezes before the dialogue to puppet/annex/raze shows off.
There's a chance your changes may be related?
I got a similar error, I'm guessing the callstack went outside the DLL or something?
Either way I chose the option to ignore error of this type, and it seems to be working now.
@HungryForFood Well do let me know of your findings when you're done :)
Hmm, where is the option to ignore error of this type, I swear I did it just now, I can't find it again....
Anyway, I think I found something better. I'll detail it from the top.
Firstly, we launch Civ 5 in debug mode, as usual.
So, when trying to use the CPU usage tool thing in VS2019, by enabling CPU profiling:
It will throw this error, presumably because it is looking for functions from the main exe instead of our DLL.
We ignore the error, and click on open details.
Click on the CPU usage tab, then change current view to modules.
Now expand the first CivilizationV_DX11.exe list, then look for CvGameCore_Expansion2.dll. Expand that dropdown, then we should now see some familiar function names.
These should contain only our stuff which we are interested in. I haven't run the game long, but the numbers seem sensible?
If CvPlayer::doTurn is only taking up 3.28% of CPU I don't think my changes can be responsible, as they're largely called in doTurn
Although it is a large chunk of the GameCoreDLL part to be fair
Ran until I crashed. Last call was this in CvGameCoreUtils.h.
Call stack was this:
Maybe we need a null check here for szString?
Or maybe it just ran out of memory?
Anyway, game ran until Renaissance, top CPU usage is as follows:
The only function I remember I changed which showed up:
I don't think that was a good test though, game was too peaceful. I'll do another test, with more warmongers and higher difficulty, and also enable BUILDINGS_THOROUGH_PREREQUISITES.
Actually ignore the CPU usage stuff, turns out I didn't select enough of the recording session.
CPU profiling of mostly just an AI capturing a city state in Classical. Highlighted is my function.
Test still running.
Another city state conquest.
And another. At this point I'm thinking I need to do the conquest as a human player though to eliminate all the noise.
Well, good news for me is, diplomacy AI doesn't seem to be ranking high on any of those. I think that means my performance optimizations were helpful...
Still need to figure out what the actual issue is, though.
I did a test by taking over an AI player, then conquering a city with the help of IGE.
Yes, it was my function.
Specifically CvCityBuildings::GetBuildingTypeFromClass when called by CvCity::UpdateHappinessFromBuildingClasses.
This line specifically.
Now that I see it, I understand why. There's 4 layers of nested for loops there, all BuildingClasses ->all BuildingClasses -> each city for the player -> each building that ever existed in the city. I'll do a quick rewrite to hopefully fix it.
The next chunk of free time I have is Tuesday night my time though, so hopefully the refactor is good.
@ilteroi How do I run the performance profiler? I tried attaching it to a release build and enabling CPU performance profiling, then hitting Break All after 50 turns of autoplay, but I just got this error:
There are reports of turn time issues...one suspected culprit is AI Rome, but may also be issues with Barbarians/City-States