QuickplayMod / quickplay

Minecraft mod that allows Hypixel users to quickly join games and execute functions on the network.
https://bugg.co/quickplay/
Other
20 stars 5 forks source link

Glyph Rendering Performance #139

Open ghost opened 3 years ago

ghost commented 3 years ago

While testing optimizations & profiling with a lot of other mods, I found QuickPlay to come up quite a bit due to the GlyphRenderer class. image The issue here is the two .stream() calls in GlyphRenderer#onRenderPlayer, Quickplay.INSTANCE.glyphs.stream().anyMatch(glyph -> glyph.uuid.toString().equals(player.getUniqueID().toString()))

Quickplay.INSTANCE.glyphs.stream().filter(thisGlyph -> thisGlyph.uuid.equals(player.getGameProfile().getId())).collect(Collectors.toList()).get(0)

This can be easily optimized to

boolean hasGlyph = false;
for (PlayerGlyph glyph : Quickplay.INSTANCE.glyphs) {
    if (glyph.uuid.toString().equals(player.getUniqueID().toString()) {
        hasGlyph = true;
        break;
    }
}

List<PlayerGlyph> glyphList = new ArrayList<>();
for (PlayerGlyph glyph : Quickplay.INSTANCE.glyphs) {
    if (glyph.uuid.equals(player.getGameProfile().getId())) {
        glyphList.add(glyph);
    }
}

PlayerGlyph glyph = glyphList.get(0);

or something similar, just to resolve the performance issue present here, as glyph's dont seem to have the ability to toggling them, so this will run every frame for every player(?).

This profiling was done in a minute, in Lobby 1 on Skyblock.

robere2 commented 3 years ago

Do you happen to know what version this was tested on? I believe I made some optimizations in 2.1.0 beta, but this very well may still be an issue as I don't think I touched that exact line of code. I imagine this is either 2.0.3 or 2.0.4?

ghost commented 3 years ago

Do you happen to know what version this was tested on? I believe I made some optimizations in 2.1.0 beta, but this very well may still be an issue as I don't think I touched that exact line of code. I imagine this is either 2.0.3 or 2.0.4?

Specifically 2.0.3 as I just downloaded JasKnightWings' mod folder to test with a lot of other mods, but the code is still present in 2.0.4 which is the latest on the forums, so I based it off of that