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:
Using the analyzer on a 1.3 autotest colony with 35 pawns appears to confirm:
Replacing System.Tuple with a custom struct type and handwritten IEqualityComparer appears to yield a small performance improvement of approx. 0.2ms per update:
Currently, label size caching uses a![Flamegraph](https://user-images.githubusercontent.com/2721291/132962215-c8be99f9-19ea-448b-bfb6-e97c684c263f.png)
System.Tuple
as the cache key with mono's defaultIEqualityComparer
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:Using the analyzer on a 1.3 autotest colony with 35 pawns appears to confirm:![Screenshot (254)](https://user-images.githubusercontent.com/2721291/132962294-1d2c3015-adfd-49c3-baa7-5262c791058f.png)
Replacing![Screenshot (253)](https://user-images.githubusercontent.com/2721291/132962315-0f73713f-9ab0-4d21-aa2f-0d7f0f39c995.png)
System.Tuple
with a custom struct type and handwrittenIEqualityComparer
appears to yield a small performance improvement of approx. 0.2ms per update:Let me know if this makes sense.