feat(serialization): Bringing over the DataStream class from UTP#398
feat(serialization): Bringing over the DataStream class from UTP#398NoelStephensUnity merged 2 commits intodevelopfrom
Conversation
… some modifications Bringing over the DataStream class from UTP into the core repo, we remove some of the unused features as well as make it work with some already defined MLAPI types. This class is also optimized to be used in a job context/burst context and has no managed allocations, as well thread safety. (Original) https://github.com/Unity-Technologies/netcode/blob/master/com.unity.transport/Runtime/DataStream.cs
mattwalsh-unity
left a comment
There was a problem hiding this comment.
Ok, given your description I'm not going to scrub this code. Glad to bring this goodness in. Should we have a ticket or something to remember to back it out later?
|
@mattwalsh-unity I went ahead and created DST-188 in the Server teams backlog item to figure out a path to Unify the two. |
| { | ||
| "name": "Unity.Multiplayer.MLAPI.Runtime", | ||
| "rootNamespace": "MLAPI", | ||
| "references": [], |
There was a problem hiding this comment.
is this change necessary? (unsafe is necessary but this one?)
There was a problem hiding this comment.
This change was made by the editor when I changed things via the UI.
| } | ||
| "hideInEditor": false, | ||
| "dependencies": { | ||
| "com.unity.collections": "0.14.0-preview.16" |
There was a problem hiding this comment.
is there a non-preview one we could use?
There was a problem hiding this comment.
Not yet, this package is expected to go out of preview in Q1 of 2021. So we shall update it when it comes out of preview (We will need for UTP as well)
This PR brings in a copy of the DataStream class from the UTP package with some modifications. It removes the NetworkCompressionModel support as well Packed support.
While yes this is code duplication, the DataStream class in UTP is about 100x faster in testing than the current BitWriter/Reader and is job/thread safe and doesn't do any sort of managed allocations or boxing. The reason we are wanting to copy this over instead of putting it into a collection package or something is the DataStream is part of UTP which is also used for DOTS Netcode which would require a bunch of work on new packages and moving things around and bring in Network specific code into Collections which is not going to happen in the near-term. So for now to get the major perf gains this will result in code duplication for a release as we work towards a more perm place for this code to be used across different packages without needing to bring in all of UTP. (potentially a shared networking package between DOTS/Current Unity)
For follow up task to Unify see: DST-188
Changelog
com.unity.multiplayer.mlapi
Testing and Documentation