RimWorld

RimWorld

405 ratings
Better GC: Mothballed and World Pawns
14
4
2
3
4
2
3
4
4
4
2
2
   
Award
Favorite
Favorited
Unfavorite
Mod, 1.4, 1.5
File Size
Posted
Updated
72.599 KB
28 May, 2023 @ 2:46pm
25 May @ 9:55am
12 Change Notes ( view )

Subscribe to download
Better GC: Mothballed and World Pawns

Description
The mod is meant to improve game performance.

The BGC mod does the following:
  • better pawn mothballing (XML patch)
  • reduces the number of world pawns that the game keeps forever through garbage collection (C# patch)
  • pawn garbage collection is customizable

For the improved mothballing, it patches some of the core/biotech hediffs, as well as the following:
  • Expanded Prosthetics and Organ Engineering
  • Diseases Overhauled
Let me know about other mods that may need a patch.

It makes little to no impact on new games (since the world's not bloated yet), but rather intended for the games that ran for a while.

Reported possible incompatibilities/special cases:
  • RIMMSqol - some pawns were reportedly removed from the cities introduced by the RIMMSqol mod. Version 1.4.0.6 of the BGC mod added "more gentle pawn cleanup" option, and when the option is on, the pawns are reportedly kept. So please use that option when playing with RIMMSqol or other mods creating long-term non-vanilla map objects storing pawns.
  • Performance Fish - PF mod description claims incompatibility, but I had reports from players claiming the two mods work just fine. The possible incompatibility seems to be related to the fact that the PF has its own Garbage Collection tweaks and settings which will be ignored by this mod. Of course, the best way to proceed is to make a backup before trying.


FAQ:
1. What's the difference between this mod and No Reasons To Avoid Mothballing?
  • This mod patches hediffs by adding allowMothballIfLowPriorityWorldPawn property, while the other mod adds alwaysAllowMothball property. The latter method is more aggressive, so you will end up with fewer ticking pawns, but with a higher risk of mothballing an important pawn that was not supposed to be mothballed.
  • On top of the 2 different properties that were added, the list of patched mods is different.
  • Most importantly, this mod removes old references to non-existing pawns


Please read before installing the mod for the details, technical or otherwise.

TLDR:
1. More pawns mothballed due to allowMothballIfLowPriorityWorldPawn tag (xml patch)
2. Better pawn cleanup by GC for those pawns that were not seen for over 1 year (runs on save load).

I've been running a colony for 7 years, and my performance eroded from 600-700 TPS to 100-120 TPS, while the savefile expanded from 25M to 80M.
I started debugging and discovered that my save file had almost 2000 pawns that were not processed by the garbage collector, and, on top of it, 200+ of those pawns were "active", so each of them "ticked".

The reason for the 200+ active pawns that were not mothballed was diseases.
The game code prevents pawn mothballing if the pawn has hediffs unless the hediff has allowMothballIfLowPriorityWorldPawn tag.
The main culprit (for my case) was the DiseasesOverhauled mod (that added a bunch of hediffs without the tag), and GeneticDrugNeed hediff added by Biotech expansion.
So the mod does just that: it patches some hediff by adding allowMothballIfLowPriorityWorldPawn tag to them.
As a result my number of ticking pawns went down from 200+ to 80+.

The second thing was bloated world pawns storage.
Pawns never get discarded if they have relations to other pawns or appear in logs somewhere.
So after you've got a bunch of big raids, you're bound to get some pawns with relations. They will be kept, probably forever.
To remedy that I added a patch that runs when the world is loaded from the save.
The patch checks if the pawn could be garbage collected (meaning, it's not an "important" pawn, e.g. not a faction leader, kidnapped, caravan member, reserved for a quest, has a corpse present on the map, etc),
then it checks that the pawn was a "WorldPawn" (meaning it was not seen by a player) for over a year (5 years if the pawn belongs to your faction), and then the patch clears pawn relations and the log entries the pawn appears in.
Then, the mod triggers a pawn mothballing and garbage collection process, so you don't have to wait until the game runs it on its own (toggleable).

In my case, it brought down the number of world pawns from 2000 to under 1000.

All in all, my savefile size went down from 80M to 58M, and my TPS went up from 100-120 to 250-270 TPS.
YMMV, depending on how many pawns you've got in your save file and whether you use Diseases Overhauled mod.

It's still in beta, though I have 150+ mods and it seems to run fine.
Please let me know if there are other common diseases that have to be patched.

Since some mods may handle pawns in unexpected ways, please make sure to make a backup copy of your save file before trying this mod.

[ko-fi.com]
Popular Discussions View All (1)
9
17 Aug, 2023 @ 9:06am
Rocketman
CrusaderRO
252 Comments
kenyer 19 Sep @ 8:05am 
This is one of those mods that should really be part of the base game.

I does exactly what it says it does and exactly why it says it does. It quadrupled the TPS in my 19 year old colony just by removing thousands of useless references from the save file.

Give this man a hug.
Lordzombey 21 Aug @ 9:59am 
Oh this is some good stuff. 3k Pawns in the garbage and I get some of those rare FPS back.
kongkim 31 Jul @ 6:39am 
@GwinnBleidd Ok thx :) Normally do the same, but performanceFish like to be on top :P
GwinnBleidd  [author] 31 Jul @ 5:28am 
@kongkim it shouldn't really matter much, though I normally put all optimization mods at the bottom of the list, just in case
kongkim 31 Jul @ 5:08am 
Is this better to load low or high in mod order?
El Kouba [BR] 29 Jul @ 8:10pm 
You have no idea what a godsend this mod was. Save went from 300MB to 180MB.

There were 12k pawns and 9.5k animals qualified for garbage collector
GwinnBleidd  [author] 28 Jun @ 5:35pm 
@mashirogod interesting. Usually, when you can't enter the map there's something in the console or error log file. Do you have something?
Plus, this mod doesn't do much (it's just a few patches). if you deactivated it and there's still an issue, then there are likely other things in play here.
mashirogod 28 Jun @ 12:09am 
The map does not load when I try to add the mod, I already had it added in another save from days ago and when I entered today it told me that it is not possible to enter the map. and when I deactivate the mod I can enter the map but it only goes at 2 fps. I don't have incompatible mods, I don't know what the problem is, I'll report it anyway.
GwinnBleidd  [author] 16 Jun @ 2:57pm 
@pig in a pumpkin I never used Caravan adventures, so I can't vouch, but as long as they use vanilla caravan structure, or at least add pawns to the list of important-to-keep-forever pawns, it should work fine
pig in a pumpkin 15 Jun @ 1:38am 
Is this compatible with caravan adventures?