RimWorld

RimWorld

Mousekin Race
This topic has been locked
sumghai  [developer] 11 May, 2024 @ 5:47pm
Performance Issues? Try this Dev Build!
A number of users have reported performance issues while running the Mousekin Race mod, which is caused by the custom hooded apparel system.

I am currently rewriting the hood system to improve performance, and have a dev build of the mod available for those who want to playtest it:

https://github.com/sumghai/MousekinRace/archive/refs/heads/hood_rewrite.zip

Please download a copy of this dev build every 2~3 days, and let me know what your FPS/TPS values are compared to the most recent stable release (v1.0.4). The more feedback I get, the quicker this gets released.

Thanks!
< >
Showing 1-6 of 6 comments
ColossalFossil 25 May, 2024 @ 2:45pm 
Hi there! I am very new to using Mousekin mod, but decided to add it to a new run that I am doing. However, I noticed that on a fresh start of the game my FPS dropped from around 120 fps to around 50-60fps. Using Dub's Performance Analyzer I noticed the Harmony patch seems to take about 3.5ms on average on every frame. Meaning that it really eats into the frame time and causes a major drop in FPS.

I looked at the GitHub repo and read the Harmony_PawnRenderTree.cs file that was recently merged into main. The Prefix method is the call that is chewing up frame time. Specifically, the WornApparel.Find which seems to be running for every pawn on the map every frame.

I was thinking that a simple check ahead of the find, could see if the pawn is capable or wearing the Mousekin hood. If the pawn is not, the Prefix function could immediately exit and not spend time searching the pawn's worn apparel.

I was also thinking that you could probably cache a list of all pawns that have hoods and make sure to expire the cache every x number of seconds. I downloaded the source but was unable to get it to compile properly. I am not used to using the VFECore library and I don't think the Dll I am using is getting the patched versions of some of the base Rimworld libraries (it was complaining about overrides not existing on the base class of Page). I tried using the Discord link in the Readme file, but it looks like it is expired. So, I figured I would post here.
sumghai  [developer] 25 May, 2024 @ 8:17pm 
Originally posted by ColossalFossil:
Hi there! I am very new to using Mousekin mod, but decided to add it to a new run that I am doing. However, I noticed that on a fresh start of the game my FPS dropped from around 120 fps to around 50-60fps. Using Dub's Performance Analyzer I noticed the Harmony patch seems to take about 3.5ms on average on every frame. Meaning that it really eats into the frame time and causes a major drop in FPS.
Just to double check, are you getting these results with the dev build in the link above? Or just the latest Steam release?

Originally posted by ColossalFossil:
I looked at the GitHub repo and read the Harmony_PawnRenderTree.cs file that was recently merged into main. The Prefix method is the call that is chewing up frame time. Specifically, the WornApparel.Find which seems to be running for every pawn on the map every frame.
So what you're saying is that, `WornApparel.Find()` is still pretty computationally expensive.

Originally posted by ColossalFossil:
I was thinking that a simple check ahead of the find, could see if the pawn is capable or wearing the Mousekin hood. If the pawn is not, the Prefix function could immediately exit and not spend time searching the pawn's worn apparel.
What do you mean by "capable"?

AFAIK, the only way to determine if the hood render node needs to be added to the pawn, is to check whether the pawn is wearing an apparel that has the hood comp. The hood is no longer a separate def, nor is it a standalone piece of apparel.

Originally posted by ColossalFossil:
I was also thinking that you could probably cache a list of all pawns that have hoods and make sure to expire the cache every x number of seconds.
I'm not sure how to cache this information in a sensible manner, without causing delays between when a player toggles a hood, and when the hood appears/disappeared.

Originally posted by ColossalFossil:
I downloaded the source but was unable to get it to compile properly. I am not used to using the VFECore library and I don't think the Dll I am using is getting the patched versions of some of the base Rimworld libraries (it was complaining about overrides not existing on the base class of Page).
I am using Publicized versions of the RimWorld base DLL.

Originally posted by ColossalFossil:
I tried using the Discord link in the Readme file, but it looks like it is expired. So, I figured I would post here.
I've updated the Discord link in the README, but there is also a working link on the Steam workshop description page.
ColossalFossil 25 May, 2024 @ 9:08pm 
Thank you for the reply and for the update to the discord link. For the DLL references, I just recently started modding and I have been using the Nuget packages from Krafs which eliminates the need to manually link reference targets. I'll take a peek at the error again tomorrow. It doesn't look like RimWorld's DLL, it's either HAR or VFE Core that it was having an issue with. It is something clearly that I didn't link correctly.

What I meant about capable is that the prefix method is running on every pawn on the entire map every frame. I am sure there are some pawns that shouldn't be checked. I'm assuming ones that don't have mouse sized heads or ones that no longer have a head would need to be checked. I also don't know enough about RimWorld yet to know if it culls out pawns that aren't displayed (i.e. they are positioned off screen).

As for the version I am running - I assume (maybe incorrectly) that since you have already merged your branch into main that you pushed it out to the Steam workshop. I probably should have checked that first. XD
ColossalFossil 25 May, 2024 @ 9:25pm 
I just tried the version for the hood fix, and it is a night and day difference. It went from about mid 40 fps back up to 120 fps. I need to stop assuming things (like merging to master means it was already published). Thank you again.
sumghai  [developer] 25 May, 2024 @ 9:46pm 
Originally posted by ColossalFossil:
I just tried the version for the hood fix, and it is a night and day difference. It went from about mid 40 fps back up to 120 fps. I need to stop assuming things (like merging to master means it was already published). Thank you again.
Glad to hear that the optimized version works after all!

Yeah, when I push to master, that doesn't mean I release it to Steam right away - this is because I am concurrently working on various other improvements alongside a major feature update, and I felt it would be unwise to publish on Steam an early release with the WIP implementation.

I usually announce actual releases with a boilerplate message within the mod's main comments section, on Discord and the Ludeon forums. If you don't see any announcements about formal releases with version numbers, then it's not a real release ;)
sumghai  [developer] 25 Jun, 2024 @ 2:32am 
Since the hood performance fix has been released as part of the v1.1 update, this discussion thread has served its purpose, and therefore can be closed.
< >
Showing 1-6 of 6 comments
Per page: 1530 50