Closed wafarm closed 3 months ago
HashMap.values iterations is slow so used a list to cache the areas
How about to use LinkedHashMap?
How about to use LinkedHashMap?
About 40ms slower than current implementation. If you want I will change to that.
Also I didn't consider too much when designing this data structure. The best way might be save all interacting areas in a chunk
OK I am going to implement a lookup based on chunks. Thanks so much for figuring out this performance issue.
May I close this PR since #42 has been merged?
Motivation
Though not on every tick, still a significant impact on MSPT.
Benchmark
Look up 1,000,000 random positions with enclosures data in our 1.21 server.
Code:
Result (10 tests each):
Changes
HashMap.values iterations is slow so used a list to cache the areas
Also removed the lockChecker for coordinates as it is not used. Possible reason: https://stackoverflow.com/questions/39152264/kotlin-how-can-i-avoid-autoboxing-garbage-in-delegated-properties but I can't fix the problem with the code in the link