-
-
Notifications
You must be signed in to change notification settings - Fork 216
Description
The current implementations of the UserStorageService (USS) and UserDiscoverer (UD) return Collections when you reference getAll methods. This means that a call to those methods would result in a very large bottleneck if you only need to process X amount of records.
The match service is an example of where this behavior fails. In order to match, it looks at all profiles which match the criteria given. If you have lots of cached players, then it will match each record before returning, preventing a filter from a later stream (a call to stream() by those that use this) from being of performance benefit.
Examples of where this type of hit is expensive is Nucleus's TP command. If you try to tab-complete, it will look to see what players match the criteria. In order to do that, it calls these methods, which result in a massive performance hit (lots of IO) if you have a large player cache.
Streams should be used here so that calls can apply filters and/or defer execution till it has to, in the cases of limits. While the 2 here should not enforce a limit, this type of change would then ensure limits used by callers would actually perform reasonably.
Related lines:
https://github.com/SpongePowered/SpongeCommon/blob/stable-7/src/main/java/org/spongepowered/common/service/user/UserDiscoverer.java#L165
https://github.com/SpongePowered/SpongeCommon/blob/stable-7/src/main/java/org/spongepowered/common/service/user/SpongeUserStorageService.java#L111
https://github.com/NucleusPowered/Nucleus/blob/sponge-api/7/src/main/java/io/github/nucleuspowered/nucleus/argumentparsers/NicknameArgument.java#L208