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

Rentable BinaryStreamWriters that write to temporary MemoryStream #317

Merged
merged 4 commits into from
May 26, 2022

Conversation

Washi1337
Copy link
Owner

Adds MemoryStreamWriterPool class that allows for renting BinaryStreamWriter instances from a pool. This significantly reduces the amount of allocated writer objects, as well as backing buffers when serializing code streams and blob signatures.

@Washi1337
Copy link
Owner Author

Before (v4.11.0):

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
HelloWorld_Read 140.71 μs 0.921 μs 0.769 μs 5.3711 0.4883 - 44 KB
HelloWorld_ReadWrite 8,492.40 μs 167.951 μs 402.400 μs - - - 12,955 KB
CrackMe_Read 29.95 μs 0.226 μs 0.188 μs 5.1270 0.4883 - 42 KB
CrackMe_ReadWrite 14,071.19 μs 269.914 μs 288.805 μs 984.3750 828.1250 484.3750 14,799 KB
ManyMethods_Read 141.28 μs 0.266 μs 0.222 μs 5.6152 0.7324 0.2441 44 KB
ManyMethods_ReadWrite 143,602.94 μs 2,869.350 μs 7,303.412 μs 7000.0000 3000.0000 1000.0000 72,342 KB
CoreLib_ReadWrite 1,224,662.14 μs 22,615.164 μs 21,154.239 μs 36000.0000 16000.0000 5000.0000 298,321 KB

After:

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
HelloWorld_Read 140.81 μs 0.946 μs 0.838 μs 5.3711 0.4883 - 44 KB
HelloWorld_ReadWrite 13,591.39 μs 271.370 μs 601.337 μs 1062.5000 890.6250 453.1250 12,946 KB
CrackMe_Read 30.64 μs 0.611 μs 1.117 μs 5.1270 0.5188 - 42 KB
CrackMe_ReadWrite 13,676.73 μs 232.188 μs 347.528 μs 984.3750 843.7500 484.3750 14,789 KB
ManyMethods_Read 140.71 μs 0.608 μs 0.539 μs 5.3711 0.4883 - 44 KB
ManyMethods_ReadWrite 136,717.57 μs 2,554.486 μs 2,389.468 μs 6000.0000 3000.0000 1000.0000 65,148 KB
CoreLib_ReadWrite 1,202,716.88 μs 23,903.364 μs 50,420.307 μs 31000.0000 15000.0000 5000.0000 255,962 KB

@Washi1337 Washi1337 merged commit 930ef22 into development May 26, 2022
@Washi1337 Washi1337 deleted the feature/rentable-memory-stream-writers branch May 26, 2022 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant