-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Replace property names with indexes in state sync #159
Comments
I can grab this after #278 is merged. After all, the keys often cost more bandwidth than their values lol Replacing keys with indexes is very easy, but there is only 1 problem once strings are replaced with indexes: Adding new properties on runtime. No idea how that should be handled in detail. |
When a new state property is added on runtime, the authority sends full states, until a Or want me to just implement indexes as is, but without covering the above edge use-cases, so diff states will be incompatible with adding/removing state properties on runtime? Also, since this feature will be done, and input has the same property format |
I'd prefer to pick this up after #321, as it might bring some refactors on the internals of Ensuring that settings are synced ( if they change ) is up to the user. So for that case, I'd just reset the diff state variables, basically restarting the process - sending the initial full state and then continuing from there. Good point on the inputs, we should update those to use indexes as well. Also just thinking out loud for a bit - we could technically use hashes instead of indexes. Both would boil down to sending numbers, but properties having the same hashes between changes might make it more resilient, by reducing index mismatches. A drawback that needs to be considered is hash collisions - not sure how common these would be. |
Seeing #347 (realtime adding properties), I agree that you have the perfect insight to implement this cleanly and without bugs (and without back and forth :P )
For my game, I'm in no rush for this as this is basically a feature for production/release to save bandwidth for the rented machine. And I'm moooooooooooooooonths away from that 😅
Sounds simple and clean 👍
Let's confirm it after #347
Since a property - independent of its instance - is to have the same index/hash order, there shouldn't be any risk of hash collisions. So for example the brawlers at forest-brawl will always have the same indexes/hashes for their properties, regardless of how many players there are. That said, the benefit of indexes would be that it's 1 byte per key, but godot sends 4 bytes (int) anyway, so using hash sounds like a better choice 👍 |
Nothing to confirm. This is a design choice.
Two property names in the same config have a chance to hash to the same value, resulting in two different properties having the same index.
An index is just a number, it has no inherent size. FYI, Godot's int is 64 bits, so 8 bytes. Though, an option is to limit the property count to 255, and send the indexes as a separate PackedByteArray followed by an array of values. This is for diff states only - for full states, we can simply send an array of values. |
I love this idea. Literally optimal bandwidth usage, without bloating code with serialization.
As a use-case, hopefully I understand this correctly: With a hash being 8 bytes (Godot's int), the chances of hashes colliding is astronomically low imo. Especially since these hash collisions don't increase per node/instance, but only for new scenes with RollbackSynchronizers. Anyway, once this check is added, the code will be bloated compared to the |
Refs #157
The text was updated successfully, but these errors were encountered: