Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving the Serializer benchmarks #343

Merged

Conversation

stebet
Copy link
Contributor

@stebet stebet commented Dec 12, 2024

  • Adding all the serializers to a parameterized benchmark.
  • Cleaning up benchmark code and config.
  • Added tests for serializing big arrays to check for memory pressure on buffers.
  • Overriding ToString() on the Serializer implementations for better reporting in BenchmarkDotNet to display the type names depending on if they are using RecyclableMemoryStreams or not.

…cleaning up the code and config for it. Also added tests for serializing arrays to check for memory pressure on buffers.
@stebet
Copy link
Contributor Author

stebet commented Dec 12, 2024

Example Output for the Serializer Benchmarks after these changes:


BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.2605)
Unknown processor
.NET SDK 9.0.101
  [Host] : .NET 8.0.11 (8.0.1124.51707), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

Toolchain=InProcessEmitToolchain  

Method Serializer Mean Error StdDev Median P95 Gen0 Gen1 Gen2 Allocated
Serialize FusionCacheCysharpMemoryPackSerializer 115.98 μs 2.286 μs 5.066 μs 117.84 μs 121.00 μs 30.2734 30.2734 30.2734 94.79 KB
Serialize FusionCacheNeueccMessagePackSerializer 126.94 μs 2.439 μs 2.903 μs 127.21 μs 131.52 μs 5.6152 - - 71.59 KB
Serialize RecyclableFusionCacheProtoBufNetSerializer 265.86 μs 3.795 μs 3.550 μs 264.64 μs 272.59 μs 5.8594 - - 78.16 KB
Serialize RecyclableFusionCacheSystemTextJsonSerializer 356.71 μs 1.461 μs 1.295 μs 356.60 μs 358.31 μs 41.0156 41.0156 41.0156 146.86 KB
Serialize FusionCacheProtoBufNetSerializer 415.61 μs 8.146 μs 10.591 μs 419.89 μs 429.02 μs 41.5039 41.5039 41.5039 336.43 KB
Serialize FusionCacheSystemTextJsonSerializer 426.36 μs 8.369 μs 9.638 μs 421.67 μs 442.30 μs 45.4102 45.4102 45.4102 146.62 KB
Serialize RecyclableFusionCacheServiceStackJsonSerializer 936.04 μs 8.862 μs 7.856 μs 935.46 μs 947.02 μs 93.7500 46.8750 46.8750 918.06 KB
Serialize FusionCacheNewtonsoftJsonSerializer 1,210.09 μs 20.580 μs 30.803 μs 1,204.01 μs 1,259.61 μs 132.8125 132.8125 132.8125 1058.85 KB
Serialize FusionCacheServiceStackJsonSerializer 1,266.18 μs 24.829 μs 46.635 μs 1,255.96 μs 1,362.64 μs 166.0156 166.0156 166.0156 1430.5 KB
Deserialize FusionCacheCysharpMemoryPackSerializer 57.00 μs 1.136 μs 3.297 μs 56.36 μs 61.91 μs 21.6675 7.0190 - 265.68 KB
Deserialize FusionCacheNeueccMessagePackSerializer 235.23 μs 5.634 μs 16.611 μs 235.16 μs 264.67 μs 21.4844 6.8359 - 265.68 KB
Deserialize RecyclableFusionCacheProtoBufNetSerializer 382.22 μs 7.095 μs 8.714 μs 377.63 μs 398.15 μs 21.4844 6.8359 - 265.99 KB
Deserialize FusionCacheProtoBufNetSerializer 422.88 μs 8.298 μs 15.585 μs 420.55 μs 453.92 μs 21.4844 6.8359 - 265.8 KB
Deserialize FusionCacheSystemTextJsonSerializer 786.63 μs 15.468 μs 24.082 μs 773.48 μs 834.97 μs 31.2500 9.7656 - 391.67 KB
Deserialize RecyclableFusionCacheSystemTextJsonSerializer 845.06 μs 16.506 μs 16.211 μs 850.36 μs 855.34 μs 31.2500 9.7656 - 391.67 KB
Deserialize FusionCacheNewtonsoftJsonSerializer 1,985.42 μs 39.572 μs 90.923 μs 1,963.25 μs 2,143.02 μs 89.8438 89.8438 89.8438 956.02 KB
Deserialize RecyclableFusionCacheServiceStackJsonSerializer 3,029.51 μs 59.674 μs 110.611 μs 2,984.85 μs 3,239.50 μs 39.0625 11.7188 - 517.84 KB
Deserialize FusionCacheServiceStackJsonSerializer 3,179.32 μs 63.524 μs 104.372 μs 3,125.10 μs 3,348.27 μs 50.7813 50.7813 50.7813 678.85 KB
SerializeAsync FusionCacheCysharpMemoryPackSerializer 94.03 μs 1.557 μs 1.530 μs 93.41 μs 96.83 μs 30.2734 30.2734 30.2734 94.79 KB
SerializeAsync FusionCacheNeueccMessagePackSerializer 146.01 μs 2.907 μs 5.738 μs 148.29 μs 152.43 μs 5.6152 - - 71.38 KB
SerializeAsync RecyclableFusionCacheProtoBufNetSerializer 290.14 μs 5.358 μs 5.012 μs 288.93 μs 299.37 μs 5.8594 - - 78.13 KB
SerializeAsync RecyclableFusionCacheSystemTextJsonSerializer 397.60 μs 1.902 μs 1.686 μs 397.67 μs 399.64 μs 42.4805 42.4805 42.4805 147.39 KB
SerializeAsync FusionCacheProtoBufNetSerializer 404.93 μs 7.604 μs 7.808 μs 406.74 μs 413.89 μs 41.5039 41.5039 41.5039 337.44 KB
SerializeAsync FusionCacheSystemTextJsonSerializer 652.98 μs 12.656 μs 17.742 μs 645.94 μs 690.03 μs 153.3203 153.3203 153.3203 594.43 KB
SerializeAsync FusionCacheNewtonsoftJsonSerializer 1,216.15 μs 23.667 μs 35.423 μs 1,212.90 μs 1,280.76 μs 132.8125 132.8125 132.8125 1058.87 KB
SerializeAsync FusionCacheServiceStackJsonSerializer 1,250.05 μs 15.451 μs 12.063 μs 1,251.37 μs 1,264.22 μs 166.0156 166.0156 166.0156 1426.52 KB
SerializeAsync RecyclableFusionCacheServiceStackJsonSerializer 1,261.47 μs 25.022 μs 29.788 μs 1,271.57 μs 1,301.45 μs 103.5156 41.0156 41.0156 918.43 KB
DeserializeAsync FusionCacheCysharpMemoryPackSerializer 58.95 μs 1.177 μs 1.611 μs 59.26 μs 60.93 μs 21.6675 7.0190 - 265.68 KB
DeserializeAsync FusionCacheNeueccMessagePackSerializer 241.53 μs 4.811 μs 9.828 μs 241.63 μs 259.28 μs 21.4844 6.8359 - 265.68 KB
DeserializeAsync RecyclableFusionCacheProtoBufNetSerializer 411.96 μs 7.462 μs 6.980 μs 411.63 μs 421.42 μs 21.4844 6.8359 - 265.99 KB
DeserializeAsync FusionCacheProtoBufNetSerializer 429.68 μs 7.737 μs 16.151 μs 426.99 μs 462.33 μs 21.4844 6.8359 - 265.8 KB
DeserializeAsync RecyclableFusionCacheSystemTextJsonSerializer 1,062.85 μs 8.811 μs 7.357 μs 1,059.91 μs 1,075.07 μs 31.2500 9.7656 - 391.98 KB
DeserializeAsync FusionCacheSystemTextJsonSerializer 1,099.91 μs 18.131 μs 16.960 μs 1,098.92 μs 1,129.99 μs 31.2500 9.7656 - 391.74 KB
DeserializeAsync FusionCacheNewtonsoftJsonSerializer 1,991.95 μs 39.544 μs 52.790 μs 1,993.03 μs 2,096.05 μs 89.8438 89.8438 89.8438 956.37 KB
DeserializeAsync RecyclableFusionCacheServiceStackJsonSerializer 2,992.85 μs 59.408 μs 85.201 μs 2,959.50 μs 3,167.55 μs 39.0625 11.7188 - 517.84 KB
DeserializeAsync FusionCacheServiceStackJsonSerializer 3,648.50 μs 44.887 μs 41.988 μs 3,646.65 μs 3,723.32 μs 50.7813 50.7813 50.7813 678.8 KB

Copy link
Collaborator

@jodydonetti jodydonetti left a comment

Choose a reason for hiding this comment

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

LGTM

@jodydonetti jodydonetti merged commit b955c9a into ZiggyCreatures:main Dec 13, 2024
1 check passed
stebet added a commit to stebet/FusionCache that referenced this pull request Dec 18, 2024
* Improving the Serializer benchmark by adding all the serializers and cleaning up the code and config for it. Also added tests for serializing arrays to check for memory pressure on buffers.
* Reverting NuGet updates
* Fixing Job config
* Minor usings cleanup

---------

Co-authored-by: Jody Donetti <[email protected]>
Co-authored-by: Stefán Jökull Sigurðarson <[email protected]>
jodydonetti added a commit that referenced this pull request Dec 18, 2024
Improving the Serializer benchmarks (#343)

* Improving the Serializer benchmark by adding all the serializers and cleaning up the code and config for it. Also added tests for serializing arrays to check for memory pressure on buffers.
* Fixing Job config
* Minor usings cleanup

---------

Co-authored-by: Jody Donetti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants