-
Bug
-
Resolution: Fixed
-
1.15.2
-
None
-
Irrelevant for the cause, but the extra startup time is larger on slower drives (HDDs) than on faster drives (SSDs).
-
Community Consensus
-
Dedicated Server
On server startup, user cache entries are read from the `usercache.json` file and added to the GameProfileCache object through a method that also stores the entire user cache. This causes a user cache of size 1000 (max size) to be read once and written 1000 times on server startup, creating a significant delay (tested 18 seconds) when running from a HDD.
Code analysis:
The GameProfileCache constructor calls GameProfileCache.load(), which reads all user cache entries and calls GameProfileCache.getProfileInfo(UUID) for each of them.
The GameProfileCache.getProfileInfo(UUID) method makes a call to GameProfileCache.save(), which stores all user cache entries to the file.
Proposed solutions:
1.
Set a boolean field to true when entering the loop in the `load()` method.
Set this field to false when exiting this loop and call the `save()` method to save all changes at once.
Do not perform saves when this boolean field is true.
2.
Add a boolean `saveToDisk` parameter to the `getProfileInfo(UUID)` method to save or don't save the file to disk at the end of this method.