Skip to content

Use System.Text.Json#53

Merged
JeremyTCD merged 16 commits intoJeringTech:masterfrom
DaniilSokolyuk:reduceallocations
Nov 25, 2019
Merged

Use System.Text.Json#53
JeremyTCD merged 16 commits intoJeringTech:masterfrom
DaniilSokolyuk:reduceallocations

Conversation

@DaniilSokolyuk
Copy link
Copy Markdown
Contributor

Before

BenchmarkDotNet=v0.12.0, OS=Windows 10.0.17763.475 (1809/October2018Update/Redstone5)
Intel Core i7-7700 CPU 3.60GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=3.0.100
  [Host] : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), X64 RyuJIT

Job=InProcess  Toolchain=InProcessEmitToolchain  
Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
INodeJSService_InvokeFromFile 181.0 us 1.20 us 1.12 us 2.9297 - - 11.99 KB
INodeJSService_InvokeFromCache 179.5 us 2.23 us 1.74 us 2.9297 - - 11.83 KB
INodeServices 186.3 us 2.12 us 1.88 us 2.4414 - - 10.37 KB

After

BenchmarkDotNet=v0.12.0, OS=Windows 10.0.17763.475 (1809/October2018Update/Redstone5)
Intel Core i7-7700 CPU 3.60GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=3.0.100
  [Host] : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), X64 RyuJIT

Job=InProcess  Toolchain=InProcessEmitToolchain  
Method Mean Error StdDev Median Gen 0 Gen 1 Gen 2 Allocated
INodeJSService_InvokeFromFile 181.5 us 4.07 us 10.13 us 177.1 us 0.9766 - - 5.8 KB
INodeJSService_InvokeFromCache 171.0 us 2.41 us 2.25 us 170.3 us 1.2207 - - 5.65 KB
INodeServices 190.3 us 2.10 us 1.86 us 189.5 us 2.4414 - - 10.37 KB

Here one more benchmark
DaniilSokolyuk/NodeReact.NET#3

@JeremyTCD
Copy link
Copy Markdown
Member

Hey looks good! I need access to the pull request branch, thanks.

@DaniilSokolyuk
Copy link
Copy Markdown
Contributor Author

@JeremyTCD Done

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 24, 2019

Codecov Report

Merging #53 into master will decrease coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #53      +/-   ##
==========================================
- Coverage   97.84%   97.77%   -0.08%     
==========================================
  Files          17       17              
  Lines         511      494      -17     
==========================================
- Hits          500      483      -17     
  Misses         11       11
Impacted Files Coverage Δ
src/NodeJS/InvocationData/InvocationRequest.cs 100% <ø> (ø) ⬆️
src/NodeJS/InvocationData/InvocationError.cs 100% <100%> (ø) ⬆️
...ementations/OutOfProcess/Http/HttpNodeJSService.cs 96.61% <100%> (-0.12%) ⬇️
...ementations/OutOfProcess/Http/InvocationContent.cs 100% <100%> (ø) ⬆️
src/NodeJS/Utils/JsonService.cs 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4661c99...4e42e34. Read the comment docs.

Daniil Sokolyuk and others added 9 commits November 25, 2019 15:42
- Added ConfigureAwait(false).
- Minor formatting, Stream is disposable, to be safe and consistent wrap in using block.
- InvocationError can't be immutable since System.Text.Json doesn't support private setters yet, looks like support will be added soon - https://github.com/dotnet/corefx/issues/38163#issuecomment-553152589. Review when System.Text.Json 5.0.0 is released.
- Not a blocking issue since this library doesn't actually use generated InvocationError instances, simply passes them to user.
- moduleSourceType can only be ModuleSourceType.Stream, ModuleSourceType.String or ModuleSourceType.File.
Copy link
Copy Markdown
Member

@JeremyTCD JeremyTCD left a comment

Choose a reason for hiding this comment

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

Almost ready to merge, just unsure about a couple of things.

@DaniilSokolyuk
Copy link
Copy Markdown
Contributor Author

@JeremyTCD
Also now deserializing is truly async, because JsonTextReader read stream synchronously, this can reduce potential thread-pool starvation

- Latency benchmarks use minimal JSON, so they do not reflect the improvement in JSON serialization/deserialization performance. Refer to benchmarks in this commit's PR for a clearer picture.
@JeremyTCD
Copy link
Copy Markdown
Member

JeremyTCD commented Nov 25, 2019

Good point!

Please add your details to the ReadMe under "Contributors" and your node project under "Projects Using this Library".

@DaniilSokolyuk
Copy link
Copy Markdown
Contributor Author

@JeremyTCD Done

DaniilSokolyuk and others added 2 commits November 25, 2019 19:39
- Benchmark couldn't find javascript module after cleaning solution.
@JeremyTCD JeremyTCD merged commit 5945488 into JeringTech:master Nov 25, 2019
@JeremyTCD
Copy link
Copy Markdown
Member

🚀 Releasing v5.0.0, bumped major version because of changes to IJsonService. Thanks for the contribution!

JeremyTCD added a commit that referenced this pull request Nov 25, 2019
Switched from Newtonsoft.Json to System.Text.Json.
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