RimWorld

RimWorld

LightsOut
This topic has been locked
Anna Yanami 14 Oct, 2021 @ 7:39pm
Garbage performance
Literally halves my TPS. Uninstalled. Make the "Check if pawn is in room" lighting update COMPLETELY FALSE, and UNLOAD IT when the option is disabled. I have the option disabled and it impacts performance to the EXTREME. Please unload the harmony patch to check for pawn presence and lighting update it when the mod option is disabled.
< >
Showing 1-5 of 5 comments
juanlopez2008  [developer] 21 Oct, 2021 @ 4:33pm 
Didn't see this until now, but to address your concern:

The harmony patch that checks for pawn "presence" isn't a tickwise thing (mostly). At the beginning of the tick I cache what room a pawn is in, and at the end of the tick I check if it has changed. That alone is not going to cause any performance repercussions even with vastly great numbers of pawns -- the normal calculations that pawn alone does during its tick are going to massively dwarf a simple pointer copy and comparison.

When that option is disabled, the comparison never takes place, and the post-tick patch exits early without ever detecting a room change. The only time the lights ever received updates when you posted this was when a room change was detected, which the mod option disabled. Light updates were not happening, and room checks were also not happening.

There is nothing intensive running at any regular interval (e.g. tickwise) that would affect your constant TPS. The MOST intensive thing that gets called every tick is multiplying the coefficient of power draw, which happens every tick for every powered bench and light. I guarantee to you that the stuff this game does every tick make even that a drop in the bucket. If you were noticing hitching as pawns enter/exit rooms, then that's something we can discuss since there's some stuff happening there -- which to be clear, is still basically nothing when compared to the existing game code.

TL;DR: out of the 30k+ people that have downloaded this mod, less than half a dozen have claimed it has affected their performance; I'm inclined to believe that if it had this dramatic of an impact on the game, I would have noticed, and at least some of the folks that downloaded it would have noticed too.
juanlopez2008  [developer] 5 Nov, 2021 @ 5:34pm 
Per your request, I loaded up a colony with 30 colonists and 10 slaves all going about their business; just to be sure, I built a room with 90 lights in it and queued up a pawn to walk in and out of the room repeatedly (this would be BY FAR the worst-case scenario and isn't even realistic). The test was done max zoomed out on 3x speed with ALL colonists and rooms in view. This is the case where long-running code will have the absolute largest impact on TPS.

Results:
  • My top patch being ran: DisablePowerDrawPatch (Postfix)
  • Max: 17.973ms
  • Avg: 0.890ms

My patches running combined to 1.797ms avg. Detecting room changes: 0.073ms avg. Recurring ticks: 1.724ms avg. Max running times came from a singular spike; the VAST majority of the time they were making almost no impact.

TPS was solid ~355-365 (goal of 360@3x), framerate dropped into the 40s.

If 40 pawns and a ridiculous number of lights barely made an impact, your numbers are unrealistic.
juanlopez2008  [developer] 5 Nov, 2021 @ 5:49pm 
Originally posted by juanlopez2008:
If 40 pawns and a ridiculous number of lights barely made an impact, your numbers are unrealistic.

IMPORTANT NOTE: this was done with the latest version of the mod, which has memoization added in the hot path for the top patch. Your original post was from prior to that addition; while I don't believe it performed that poorly, I certainly do not have performance data from that time period, so I can't at all say that it didn't perform that poorly then, I can only say that it doesn't perform that poorly now.
juanlopez2008  [developer] 6 Nov, 2021 @ 1:17pm 
I did some extra looking this morning and got significant gains in performance.

I've got the whole mod down to ~0.07ms avg on 1x speeds, and ~0.5ms avg on 3x speed, down from the 1.797ms total on 3x yesterday.

Recurring tick time on 3x speed got brought down to <0.425ms, which is a lot better than before, regardless of whether the previous performance was acceptable or not.

Hopefully that addresses your concerns!
Last edited by juanlopez2008; 6 Nov, 2021 @ 1:18pm
juanlopez2008  [developer] 12 Nov, 2021 @ 5:10am 
Originally posted by Rika Voort:
Could you try using this with rimthreaded then? I used to use this with rimthreaded and even with the automatic lights off the patch incurred performance.

RimThreaded is asking for trouble. I can’t guarantee my mod can work with RimThreaded because collections are NOT threadsafe in RimWorld, so that mod is free to trample them and generate exceptions in my mod.
Last edited by juanlopez2008; 12 Nov, 2021 @ 5:10am
< >
Showing 1-5 of 5 comments
Per page: 1530 50