[A16] Zhentar's Experimental Performance & Memory Fixes

Started by Zhentar, January 30, 2017, 03:31:21 PM

Previous topic - Next topic

Zhentar

I don't want to release these as finished mods, since they muck about with important parts of RimWorld's inner workings, and I have not given them particularly thorough testing. But I also know that these issues are seriously affecting some players' gameplay, so I want to put them out there for the people who are willing to accept some risk to try to find fixes.

World Pawn GC
"World" pawns are pawns that are kept around in the background, and simulated, tracked so that you can experience things like raiders coming back in later raids, or keep your colonist's family members in existence when they aren't on the map. A lot of them can build up over time; in a large, old colony they can easily make up 50% of the time taken to calculate each tick. When traveling on the world, with out any active colony maps, it can be 90% or more. This mod implements a garbage collector for world pawns. It looks over all of the world pawns, figures out which ones are related to "important" pawns (e.g. your colonists), and throws away the rest.

I suspect that this mod will have a larger impact over time than it will immediately after it is installed. Additionally, it will be able to delete more pawns if you butcher/incinerate raider corpses rather than having large graveyards.
https://drive.google.com/file/d/0B_iRcVI-TJMZZFpVcG45SGcwX00/view?usp=sharing&resourcekey=0-3x1FVttQeizTr7KoMMYJ7g

Memory Leak Fix
Each time a map is created & destroyed (e.g. during faction base raids), RimWorld leaks quite a bit of memory. This mod fixes one of the main causes and significantly mitigates another (unfortunately not fixed because I cannot for the life of me figure out how it is happening).

This will probably reduce or eliminate memory leaks and will probably not break anything. I think. (Note that this a test update to Zhentar's Vanilla Fixes, so it also includes the other fixes in there)
https://github.com/Zhentar/ZhentarFix/releases/download/v1.5alpha/ZhentarFix1.5_alpha.zip

skullywag

Top work as always Zhentar. Hope this helps Tynan and gang as well.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

BlackGyver

Holy moly guacamole, this is exactly what I needed! Having Hospitality installed and a 10+ years base means a slow, stuttering death. I'm going to try this out right now!

KingKnee

#3
Hi Zhentar, I'm still using the even earlier version of WorldPawnGC so I will definitely give it a shot. I dunno if you caught my reply last time but your older version was removing pawns buried in sarcophagi, which seems unintended?

In any case, thanks for working on this, imho huge challenge with this game.

EDIT.

Removing pawns from graves after a while would be great, making them empty again ofc.

kilgoar


Zhentar

Quote from: KingKnee on January 30, 2017, 09:24:35 PM
Hi Zhentar, I'm still using the even earlier version of WorldPawnGC so I will definitely give it a shot. I dunno if you caught my reply last time but your older version was removing pawns buried in sarcophagi, which seems unintended?

I did see that. I checked my code and it's impossible, so you were clearly hallucinating.

(Okay, I've been developing software long enough to know that just because it's impossible doesn't mean users aren't going to run into it. But I haven't tried reproducing/investigating it yet.)

mega_newblar

For what its worth I activated the GC mod on an in-progress save (bout 8 colonists) and my sarcophagus still contained the correct bodies. Seems to be working.   

Also in general I do notice that the game operates on 4x speed much more smoothly, and the choppiness from zooming out and scrolling around is lessened to a noticeable degree.   


Great mod, thank you for releasing it.

ShadowDark7

I am the unashamed owner of a potato pc, and this mod helped immensely with the frames. Incredible job!

kilgoar

Okay so I've been at work spamming worldpawns and repeatedly reloading pirate outposts, etc. I would've done more & I will do more but this caravan struck a tragic end. It's still pretty damn slow, so it should be useful.

[attachment deleted by admin due to age]

kilgoar

Quote from: kilgoar on February 01, 2017, 03:32:19 AM
Okay so I've been at work spamming worldpawns and repeatedly reloading pirate outposts, etc. I would've done more & I will do more but this caravan struck a tragic end. It's still pretty damn slow, so it should be useful.
I forgot to mention I noticed a few possible gameplay side effects of the fix. I was able to down a pawn, loot it, and come back and repeat, gaining the same eq again. Wham. Two superior plasteel longswords. Also had identical clothes, name, stats, etc. Could just be a fluke but that's never happened before. Also maybe I got confused but it sure looked like a slave disappeared from a trading outpost. I don't know if they'll also reappear upon repeated visits or over time, and not that it's a change that affected my gameplay but it might be possible.

Rilamus

This is fantastic work, I'm ecstatic that this exists

Zhentar

Quote from: kilgoar on February 01, 2017, 03:51:36 AM
I forgot to mention I noticed a few possible gameplay side effects of the fix. I was able to down a pawn, loot it, and come back and repeat, gaining the same eq again. Wham. Two superior plasteel longswords. Also had identical clothes, name, stats, etc. Could just be a fluke but that's never happened before. Also maybe I got confused but it sure looked like a slave disappeared from a trading outpost. I don't know if they'll also reappear upon repeated visits or over time, and not that it's a change that affected my gameplay but it might be possible.

That first one sounds just plain bizarre. No idea what could have been going on there, but I'll keep an eye out.

The second, I'm pretty sure is a bug with my code. I'll look into fixing it.

kilgoar

Quote from: Zhentar on February 01, 2017, 11:44:15 AM
Quote from: kilgoar on February 01, 2017, 03:51:36 AM
I forgot to mention I noticed a few possible gameplay side effects of the fix. I was able to down a pawn, loot it, and come back and repeat, gaining the same eq again. Wham. Two superior plasteel longswords. Also had identical clothes, name, stats, etc. Could just be a fluke but that's never happened before. Also maybe I got confused but it sure looked like a slave disappeared from a trading outpost. I don't know if they'll also reappear upon repeated visits or over time, and not that it's a change that affected my gameplay but it might be possible.

That first one sounds just plain bizarre. No idea what could have been going on there, but I'll keep an eye out.

The second, I'm pretty sure is a bug with my code. I'll look into fixing it.
The first one was bizarre. Also maybe I didn't explain. Since I didn't kill the pawn and I reloaded the faction outpost, some data that should have been deleted was kept. I suspect it's related to the performance mods but maybe not.

https://www.twitch.tv/videos/118782700

Item duplicating fun starts at 59 minutes.

Riccars

Does world pawn do anything about pawns already in the save before the mod is enabled? I added it after my game got laggy and didn't see a performance difference or filesize difference.

Zhentar

Just how much gets cleaned up will vary, but you should see at least some small change. However the cleanup only runs once every 6 game hours, so you may have to wait a bit to see results. It will log an entry in the dev mode log listing all the pawns it deleted when it runs, so you can check that to see if it's run/done anything.