TINKERPOP-2349 Migrate JSON serialization to System.Text.Json in Gremlin.NET#1273
Merged
Conversation
jorgebay
reviewed
Apr 1, 2020
jorgebay
left a comment
Contributor
There was a problem hiding this comment.
Looks good, this should simplify dependency management in the future.
This is a breaking change but its safe to do it in 3.5.0.
I've added a comment below.
2cbcbfb to
a1a8e1e
Compare
Results from a simple benchmark with BenchmarkDotNet showed that this improves the performance of the deserialization roughly by a factor of 2. The deserialization now also allocates far less memory, by a factor of ~7 which also results in less garbage collections. The performance of the serialization however stayed basically the same. It got even slightly slower by ~4% in this benchmark, but it also allocates a bit less memory (-12%). This seems acceptable in my opinion, given that it is only a very small increase, especially compared to the differences for the deserialization and because it allocates less memory now. Output from BenchmarkDotNet: Before: | Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | |---------------- |---------:|---------:|---------:|-------:|-------:|------:|----------:| | Serialization | 22.41 us | 0.616 us | 0.659 us | 1.5564 | - | - | 9.72 KB | | Deserialization | 40.50 us | 1.075 us | 1.150 us | 6.3477 | 0.6104 | - | 39.06 KB | After: | Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | |---------------- |---------:|---------:|---------:|-------:|------:|------:|----------:| | Serialization | 23.25 us | 0.103 us | 0.091 us | 1.3733 | - | - | 8.58 KB | | Deserialization | 25.89 us | 0.583 us | 0.545 us | 0.9155 | - | - | 5.74 KB |
a1a8e1e to
0ea7336
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/TINKERPOP-2349
Results from a simple benchmark with BenchmarkDotNet showed that this improves the performance of the deserialization roughly by a factor of 2. The deserialization now also allocates far less memory, by a factor of ~7 which also results in less garbage collections. The performance of the serialization however stayed basically the same. It got even slightly slower by ~4% in this benchmark, but it also
allocates a bit less memory (-12%). This seems acceptable in my opinion, given that it is only a very small increase, especially compared to the differences for the deserialization and because it allocates less
memory now.
Output from BenchmarkDotNet:
Before:
After:
Another advantage of using System.Text.Json is that it supports
Span<T>so we could make use of that in the future to reduce memory allocations in the driver even more.VOTE +1