Summary
I’ve been optimizing the speed of a custom dynamic persistable
logic and noticed that FitsInPlayerMap
is externally slow.
Please select what you are reporting on:
Verse
What Type of Bug are you experiencing?
Other
Steps to Reproduce
- Create a persistable class with a
[int]int
map field - Fill the map with 1000 elements
- Profile the persistable object
Expected Result
The operation should be very fast or there should be ways to check if the data will fit in a more optimized way that will not cause the server to hitch.
Observed Result
Profiled time for such a case exceeds 30-40ms which will hitch the server. That’s for a single operation. For many players this will require load balancing, but even then 30-40ms is too much as under perfect conditions the server has 33.33ms window budge for a single tick (30 TPS) or only 16.66ms (60TPS).
Platform(s)
UEFN (v36.30)
Additional Notes
Surely one can argue that 1000 elements is a lot or even plenty to persist the most data one would ever need. However the persistence goes up to 128kb for two weak maps each, where 1000 integer elements in a map isn’t close to the max size of a single weak map. Trying to save full data sets into two weak maps will have a very large hitch that can potentially even cause network error and shut down the game session server.
At this point one should avoid the usage of FitsInPlayerMap
altogether and only check if the full data set will really fit at development time. However this is also not ideal as for dynamically growing player saves, one need to check the size at runtime in order to avoid crashing the server, but in doing so the server will likely hitch at large data sets.