kbatbouta / RimWorld-RocketMan

RocketMan is a RimWorld mod that is designed to improve RimWorld performance.
Eclipse Public License 2.0
48 stars 7 forks source link

Optimize label size caching #34

Closed mszabo-wikia closed 2 years ago

mszabo-wikia commented 3 years ago

Currently, label size caching uses a System.Tuple as the cache key with mono's default IEqualityComparer implementation, which seems to add noticeable overhead. I originally came across this in a flamegraph generated over an interval of 466 seconds on an 86 pawn colony on 1.2: Flamegraph

Using the analyzer on a 1.3 autotest colony with 35 pawns appears to confirm: Screenshot (254)

Replacing System.Tuple with a custom struct type and handwritten IEqualityComparer appears to yield a small performance improvement of approx. 0.2ms per update: Screenshot (253)

Let me know if this makes sense.