-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance optimization of chat #3634
base: master
Are you sure you want to change the base?
Conversation
I changed a little compared to chat-optimzation-v2. Better javadoc on Deserializable |
Bukkit servers don't send this in json already? If yes, can't it be used? |
Thats what this pr does. It keeps the json string unless basecomponent requested by other code or a setter used to override. In newer versions, they do not send json string, but they send nbt. In that case, this PR will omit the conversion of nbt to json, but due to nbt having no size prefix, it needs to read the bytes into nbt. |
Sounds great. 😎 🚀 |
BungeeCord/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java Line 154 in 7d438f6
Maybe I messed something up, I'm not sure. It happens with BungeeTabListPlus. Maybe it should be like that, I did that and there's no error. BungeeCord/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java Line 94 in 7d438f6
BTW I guess this patch won't help with BTLP? |
Nice catch, your correction looks correct. |
Fixed the same thing in other places. And yes, this patch likely does not help performance of bungeetablistplus. |
I'm testing this in production, other that the error that I sent you I don't see any problems. Here are the profilers, I think the performance is better. :) |
Fixed stupid mistake in writeBaseComponenet Janmm14@e275e38 Tested basic functionality. |
Stop use of subclass for static method call. Make test helper methods static.
Can you please merge/rebase the remaining? Thanks |
Thanks |
@@ -0,0 +1,28 @@ | |||
package net.md_5.bungee.protocol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these new classes should go in a separate package (util or otherwise)
@@ -18,7 +22,7 @@ public class BossBar extends DefinedPacket | |||
|
|||
private UUID uuid; | |||
private int action; | |||
private BaseComponent title; | |||
private Deserializable<Either<String, SpecificTag>, BaseComponent> title; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think every instance is "Deserializable<Either<String, SpecificTag>, BaseComponent>", so we should probably create a helper "ChatDeserializable extends Deserializable<Either<String, SpecificTag>, BaseComponent>"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a ChatDeserializable is unfortunaly not working as an alias and would require all implementations to be doubled.
If you want it shorter, the solution I see is to get rid of generics and just start worrying about extendability and code reuse if we actually need it at some later point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a tough one. Maybe leave Deserializable and specialise the implementations?
protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java
Outdated
Show resolved
Hide resolved
@@ -163,6 +164,16 @@ public static String toString(Object object) | |||
return gson.toJson( object ); | |||
} | |||
|
|||
public static String toString(Content content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for these being added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During work on this, I noticed #3629 and wanted to remove any invocations of toString(Object)
, and here I jsut forgot to mention it.
I would further suggest to deprecate the toString(Object) method here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added deprecation
6cb2be9
to
0f23c99
Compare
|
Please do another review. |
Hopefully, this gets merged. It will set a precedent for future packet decoding/handling as well. The serialization/deserialization process is likely only going to become more complex/heavy with each new Minecraft version release. |
Just some offtopic chatting: Other proposed speedups in packet handling code are:
|
Moved unrelated changes I did while working on this PR to their own PRs: |
Stop use of subclass for static method call. Make test helper methods static.
1.21 update? 🚀 Also I don't have any problems with this patch, I think it should be implemented. 🔥 |
I agree it should be implemented too, but it's going to be very plugin-breaking. A plugin using the BossBar packet for instance, the methods get/set#BaseComponent would no longer exist due to the wrapper replacing the BaseComponent obviously. So it wouldn't be a quick and painless merge. Will require a large amount of plugins to update. |
There may be workarounds and plugin authors can update their projects, these classes received updates not so long time ago anyway. |
Packets / protocol is not official part of the API. |
…st existing code to use new types
…ers and split either-sourced and new-only-sourced.
Updated for 1.21 with rebase |
BaseComponent
is questioned, save only String/Tag).To achieve this, a
Deserializable
interface has been added with a few implementations. Existing getters, setters and constructors have been kept as they were, added are new "raw" versions of it, exposing the Deserializable itself.These performance optimizations are based on the assumption that most plugins and use cases do not involve reading mc-server-sent chat/tablist header/footer/entries inside bungeecord.
Basic testing has been done.