Performance: Excess memory allocation in MyDataReceiver.UpdateBroadcastersInRange
Game version: 1.200.032
This method always allocates new HashSets, posing a constant GC pressure:
HashSet<long> longSet1 = new HashSet<long>(); HashSet<long> longSet2 = new HashSet<long>();
It should use pooled objects and just clear them instead of allocating new ones.
Best is to use a per-thread array of instances: ThreadLocal<HashSet<long>>
For a working solution please see MyDataReceiverPatch in https://github.com/viktor-ferenczi/performance-improvements
Alternative would be to use a bucket pool: MyConcurrentBucketPool<HashSet<long>>
Do not add these instances as members to MyDataReceiver, because it would involve a lot of unnecessary objects, increasing the overall memory consumption and lowering cache locality.
Run this test world in DS to reproduce (OneDrive due to its size): https://1drv.ms/u/s!AqEgz8G_d8TSh8wPzLoPp_dQDBRb7g?e=eBhsuv