Skip to content

TINKERPOP-2349 Migrate JSON serialization to System.Text.Json in Gremlin.NET#1273

Merged
FlorianHockmann merged 1 commit into
masterfrom
TINKERPOP-2349
Apr 9, 2020
Merged

TINKERPOP-2349 Migrate JSON serialization to System.Text.Json in Gremlin.NET#1273
FlorianHockmann merged 1 commit into
masterfrom
TINKERPOP-2349

Conversation

@FlorianHockmann

@FlorianHockmann FlorianHockmann commented Apr 1, 2020

Copy link
Copy Markdown
Member

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:

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

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

@FlorianHockmann FlorianHockmann requested a review from jorgebay April 1, 2020 10:01

@jorgebay jorgebay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread gremlin-dotnet/glv/Gremlin.Net.csproj.template Outdated

@jorgebay jorgebay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, VOTE +1

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 |
@FlorianHockmann FlorianHockmann merged commit 0ea7336 into master Apr 9, 2020
@FlorianHockmann FlorianHockmann deleted the TINKERPOP-2349 branch April 9, 2020 08:42
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.

2 participants