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

Struct serialization contexts #356

Merged
merged 2 commits into from
Sep 17, 2022

Conversation

Washi1337
Copy link
Owner

Turns the following classes into (readonly) structs

  • BlobSerializationContext
  • CustomAttributeArgumentWriter

@Washi1337 Washi1337 added enhancement dotnet Issues related to AsmResolver.DotNet performance labels Sep 17, 2022
@Washi1337 Washi1337 added this to the 5.0.0 milestone Sep 17, 2022
@Washi1337 Washi1337 changed the title Struct serialization contects Struct serialization contexts Sep 17, 2022
@Washi1337
Copy link
Owner Author

This seems to reduce gen0 and gen1 allocations somewhat when rewriting System.Private.Xml (~1.3% of total allocated memory).

Benchmarks:

Old:
Method Mean Error StdDev Gen0 Gen1 Gen2 Allocated
HelloWorld_Read 148.17 us 1.430 us 1.337 us 5.6152 0.4883 - 46.9 KB
HelloWorld_ReadWrite 491.73 us 3.239 us 3.030 us 33.2031 6.8359 - 274.62 KB
CrackMe_Read 33.01 us 0.404 us 0.378 us 5.4321 0.5493 - 44.73 KB
CrackMe_ReadWrite 401.68 us 2.678 us 2.505 us 35.6445 6.8359 - 291.3 KB
ManyMethods_Read 146.95 us 1.362 us 1.274 us 5.6152 0.4883 - 46.91 KB
ManyMethods_ReadWrite 151,701.85 us 2,990.635 us 3,672.769 us 6000.0000 3000.0000 1000.0000 50448.83 KB
SystemPrivateCoreLib_ReadWrite 1,181,859.78 us 17,578.048 us 16,442.517 us 35000.0000 17000.0000 6000.0000 280606.04 KB
SystemRuntimeLib_ReadWrite 4,594.38 us 34.484 us 28.795 us 468.7500 226.5625 - 3886.43 KB
SystemPrivateXml_ReadWrite 969,957.21 us 16,480.738 us 15,416.092 us 28000.0000 13000.0000 4000.0000 229169.52 KB
New:
Method Mean Error StdDev Gen0 Gen1 Gen2 Allocated
HelloWorld_Read 150.41 us 1.840 us 1.631 us 5.6152 0.4883 - 46.9 KB
HelloWorld_ReadWrite 504.08 us 6.855 us 6.412 us 34.1797 7.8125 0.9766 273.64 KB
CrackMe_Read 33.31 us 0.631 us 0.591 us 5.4321 0.6104 - 44.73 KB
CrackMe_ReadWrite 411.59 us 6.813 us 7.846 us 35.1563 5.8594 - 290 KB
ManyMethods_Read 150.38 us 1.189 us 1.113 us 5.6152 0.4883 - 46.91 KB
ManyMethods_ReadWrite 150,916.40 us 2,924.203 us 3,481.055 us 5750.0000 2750.0000 1000.0000 50057.52 KB
SystemPrivateCoreLib_ReadWrite 1,199,795.91 us 21,935.912 us 19,445.615 us 35000.0000 17000.0000 6000.0000 276936.52 KB
SystemRuntimeLib_ReadWrite 4,863.79 us 96.235 us 90.018 us 468.7500 210.9375 - 3866.82 KB
SystemPrivateXml_ReadWrite 1,000,291.73 us 19,112.609 us 21,243.614 us 27000.0000 13000.0000 4000.0000 226085.8 KB

@Washi1337 Washi1337 merged commit dd01769 into development Sep 17, 2022
@Washi1337 Washi1337 deleted the feature/struct-blob-serialization-context branch September 17, 2022 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet Issues related to AsmResolver.DotNet enhancement performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant