Skip to content
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

WIP: Ddata serialization opts #7014

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

to11mtm
Copy link
Member

@to11mtm to11mtm commented Dec 3, 2023

Changes

This is a substantial overhaul of ReplicatedDataSerializer to do the following:

  1. Use Pools for Protobuf GZip/GUnzip. CommunityToolKit is used for this due to it's large range of framework support and overall stability.
  2. Use Pooled lists for some intermediate builder cases
  3. Cache certain type bytestrings used by ReplicatedDataSerializer/SerializerSupport
  4. Use Cached compiled Expressions in place of Invoke where possible.

####Still To try/Do:

  • Will using NonBlocking.ConcurrentDictionary be preferable for Compiled expression caches?
  • Clean up Type composition
  • Clean up formatting
  • Update API

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Latest dev Benchmarks

ORDictionary Before:

Method NumElements NumNodes Mean Error StdDev Gen0 Gen1 Allocated
Serialize_ORDictionary 25 10 1.646 ms 0.0321 ms 0.0357 ms 214.8438 17.5781 987.41 KB
Deserialize_ORDictionary 25 10 1.432 ms 0.0130 ms 0.0115 ms 324.2188 64.4531 1498.57 KB

LWWDictionary Before:

Method KeyType ValueType NumElements NumNodes Mean Error StdDev Gen0 Gen1 Allocated
Serialize_LWWDict TestKey TestKey 25 10 1,387.8 us 11.01 us 9.19 us 134.7656 15.6250 627.64 KB
Deserialize_LWWDict TestKey TestKey 25 10 915.6 us 8.23 us 7.30 us 158.2031 26.3672 731.62 KB
Serialize_LWWDict TestKey TestVal 25 10 670.3 us 6.71 us 5.24 us 104.4922 11.7188 484.48 KB
Deserialize_LWWDict TestKey TestVal 25 10 594.1 us 3.43 us 2.86 us 120.1172 20.5078 554.43 KB
Serialize_LWWDict TestVal TestKey 25 10 1,310.7 us 14.58 us 13.64 us 130.8594 15.6250 609.88 KB
Deserialize_LWWDict TestVal TestKey 25 10 869.9 us 11.10 us 10.39 us 154.2969 25.3906 712.53 KB
Serialize_LWWDict TestVal TestVal 25 10 586.3 us 7.95 us 7.04 us 100.5859 11.7188 466.54 KB
Deserialize_LWWDict TestVal TestVal 25 10 548.5 us 3.58 us 3.35 us 116.2109 21.4844 534.84 KB

ORSet before:

Method NumElements NumNodes Mean Error StdDev Gen0 Gen1 Allocated
Serialize_ORSet 25 10 577.4 us 10.80 us 10.61 us 87.8906 7.8125 406.94 KB
Deserialize_ORSet 25 10 489.0 us 9.27 us 8.22 us 94.7266 14.6484 436.8 KB

This PR's Benchmarks

ORDictionary After:

Method NumElements NumNodes Mean Error StdDev Gen0 Gen1 Allocated
Serialize_ORDictionary 25 10 1.370 ms 0.0180 ms 0.0159 ms 189.4531 15.6250 873.66 KB
Deserialize_ORDictionary 25 10 1.068 ms 0.0125 ms 0.0110 ms 291.0156 3.9063 1342.23 KB

LWWDictionary After:

Method KeyType ValueType NumElements NumNodes Mean Error StdDev Gen0 Gen1 Allocated
Serialize_LWWDict TestKey TestKey 25 10 1,314.2 us 13.60 us 12.06 us 128.9063 15.6250 592.43 KB
Deserialize_LWWDict TestKey TestKey 25 10 805.8 us 5.30 us 4.70 us 137.6953 0.9766 634.77 KB
Serialize_LWWDict TestKey TestVal 25 10 648.2 us 12.36 us 12.14 us 97.6563 10.7422 450.66 KB
Deserialize_LWWDict TestKey TestVal 25 10 534.9 us 4.17 us 3.49 us 99.6094 0.9766 459.15 KB
Serialize_LWWDict TestVal TestKey 25 10 1,240.5 us 21.59 us 19.14 us 125.0000 13.6719 574.79 KB
Deserialize_LWWDict TestVal TestKey 25 10 785.6 us 4.82 us 4.28 us 133.7891 0.9766 615.27 KB
Serialize_LWWDict TestVal TestVal 25 10 573.7 us 10.62 us 9.41 us 93.7500 10.7422 432.66 KB
Deserialize_LWWDict TestVal TestVal 25 10 503.0 us 9.07 us 8.49 us 94.7266 16.6016 439.51 KB

ORSet After:

Method NumElements NumNodes Mean Error StdDev Gen0 Gen1 Allocated
Serialize_ORSet 25 10 496.4 us 3.86 us 3.42 us 82.0313 7.8125 377.72 KB
Deserialize_ORSet 25 10 438.0 us 3.61 us 3.20 us 75.1953 12.2070 345.87 KB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant