[ 
https://issues.apache.org/jira/browse/TINKERPOP-2349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17072603#comment-17072603
 ] 

ASF GitHub Bot commented on TINKERPOP-2349:
-------------------------------------------

FlorianHockmann commented on pull request #1273: TINKERPOP-2349 Migrate JSON 
serialization to System.Text.Json in Gremlin.NET
URL: https://github.com/apache/tinkerpop/pull/1273
 
 
   https://issues.apache.org/jira/browse/TINKERPOP-2349
   
   .NET Core 3.0 is added as a target framework as it already includes support 
for `System.Text.Json` and therefore doesn't need the NuGet package.
   
   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>`](https://docs.microsoft.com/en-us/archive/msdn-magazine/2018/january/csharp-all-about-span-exploring-a-new-net-mainstay)
 so we could make use of that in the future to reduce memory allocations in the 
driver even more.
   
   VOTE +1
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Switch from Newtonsoft.Json to System.Text.Json
> -----------------------------------------------
>
>                 Key: TINKERPOP-2349
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2349
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: dotnet
>            Reporter: Florian Hockmann
>            Assignee: Florian Hockmann
>            Priority: Major
>
> .NET Core 3.0 [came with a new built-in JSON serialization 
> library|https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-apis/]
>  _System.Text.Json_ which probably becomes the standard JSON library for 
> .NET. It offers a better performance while allocating less memory compared to 
> Newtonsoft.Json because it is using new technologies such as {{Span<T>}}.
> For users of .NET Core 3.x this also has the nice benefit that the JSON 
> implementation is directly included in the .NET Core framework which solves 
> possible version conflicts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to