Closed matipoirierg closed 7 months ago
Not sure if there is any way to make it any faster, (atleast for this specific case) just at a quick glance
whats causing it is this function here
public Optional<TownClaim> getClaimAt(@NotNull Chunk chunk, @NotNull HuskTowns plugin) {
return claims.entrySet().stream()
.filter(entry -> entry.getValue().stream().anyMatch(claim -> claim.getChunk().equals(chunk)))
.findFirst()
.flatMap(entry -> entry.getValue().stream()
.filter(claim -> claim.getChunk().equals(chunk))
.findFirst()
.flatMap(claim -> plugin.findTown(entry.getKey())
.map(town1 -> new TownClaim(town1, claim))))
.or(() -> adminClaims.stream()
.filter(claim -> claim.getChunk().equals(chunk))
.findFirst()
.map(claim -> new TownClaim(plugin.getAdminTown(), claim)));
}
and stream filtering is always going to be slow but, there might be a better way of doing it, someone smarter than me will know more than me though
Not sure if there is any way to make it any faster, (atleast for this specific case) just at a quick glance
whats causing it is this function here
public Optional<TownClaim> getClaimAt(@NotNull Chunk chunk, @NotNull HuskTowns plugin) { return claims.entrySet().stream() .filter(entry -> entry.getValue().stream().anyMatch(claim -> claim.getChunk().equals(chunk))) .findFirst() .flatMap(entry -> entry.getValue().stream() .filter(claim -> claim.getChunk().equals(chunk)) .findFirst() .flatMap(claim -> plugin.findTown(entry.getKey()) .map(town1 -> new TownClaim(town1, claim)))) .or(() -> adminClaims.stream() .filter(claim -> claim.getChunk().equals(chunk)) .findFirst() .map(claim -> new TownClaim(plugin.getAdminTown(), claim))); }
and stream filtering is always going to be slow but, there might be a better way of doing it, someone smarter than me will know more than me though
Catch another spike that actually dropped my tps to 17, but I think it's a different function this time https://spark.lucko.me/ls3a0fXsj9
Different listener but same function, its getting the claim object (if it exists) and checking the flag for that event, it might be better to cache all claims at startup but that could cause higher ram, again not too sure the best way to go about this
Different listener but same function, its getting the claim object (if it exists) and checking the flag for that event, it might be better to cache all claims at startup but that could cause higher ram, again not too sure the best way to go about this
thanks for the clarification
Here is also a performance issue
This situation is worse than I anticipated. My TPS is dropping to 14-15, especially when there are high player counts.
Seems like we need to take a look at some stream logic & make some optimisations :)
Going to close this as a duplicate of #425 :)
Hello, I would like to know if it's possible to improve the performance of the plugin, as I'm experiencing significant increases in MSPT. It's not urgent, since despite everything, my server remains stable at 20-19 TPS, but I believe there is room for improvement, especially if we think about scalability. I'm using latest build 3.0.2
https://spark.lucko.me/6cCNCHKC7y