feat!: Use STJ for SendPipeline serializer instead of Newtonsoft#468
feat!: Use STJ for SendPipeline serializer instead of Newtonsoft#468JR-Morgan wants to merge 49 commits into
SendPipeline serializer instead of Newtonsoft#468Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #468 +/- ##
==========================================
+ Coverage 71.46% 73.71% +2.25%
==========================================
Files 355 365 +10
Lines 14377 14745 +368
Branches 1209 1218 +9
==========================================
+ Hits 10275 10870 +595
+ Misses 3704 3468 -236
- Partials 398 407 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4558f3e to
72f6898
Compare
ea0a9ed to
87dc3ac
Compare
| new ArrayBufferWriterPooledObjectPolicy<byte>() | ||
| { | ||
| InitialCapacity = 512, | ||
| MaximumRetainedCapacity = 100 * 1024 * 1024, |
There was a problem hiding this comment.
out of curiosity, why 100MB?
There was a problem hiding this comment.
MaximumRetainedCapacity is the maximum size a rented buffer can be for it to be placed back in the pool to be reused.
If you pick a number that' too high, you end up keeping super large buffers around in memory for longer than is needed (increasing peak memory usage)
If you pick a number that's too small, then you'll see greater buffer re-sizing for large objects, (leads to more garbage allocated)
I picked 100MB because most objects are going to be well under this limit. We've only seen objects get >100MB in super large models.

This is a semi-experimental change to replace newtonsoft with System.Text.Json for the new send pipeline serializer
See https://www.notion.so/speckle/Introducing-System-Text-Json-to-packfile-based-serializer-SendPipleine-357b78fc7aa6805bb472ca09b980b7fd
for the full context.
Serializer Benchmarks
Medium size model: https://app.speckle.systems/projects/bf5b49215c/models/0d573b9a34
NET 10
NET 8.0
NET 4.8
Larger model (conf)
NET10
NET 4.8.1
TODO:
I'm expecting the .NET8 and .NET 10 targets to be most benefited.✅Memory allocations should be measurably lower.✅Raw speed should also be improved too✅.netstandard2.0 less so (I'm not expecting any regressions, but we should test)✅for .netstandard2.0 we've introduced a dependency on STJ. Lets determine if this will be a problem. we may be able work around it with ILRepack, or by lowering the version requirement.✅ - version lowered down to 5.xEnsure test coverage of the simple stuff (id generation etc...)✅IL repack System.Memory? or no?❎Can't since we need to expose theIBufferWriterinterface from Speckle.Sdk.Depedencies + no need, STJ pulls it in anyway.