-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Use optimized hash creation methods on .NET 5+ #67999
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
Conversation
bb641e1 to
d086859
Compare
src/Workspaces/Core/Portable/Workspace/Solution/Checksum_Factory.cs
Outdated
Show resolved
Hide resolved
d086859 to
48e9cc5
Compare
| return From(hash); | ||
| #elif NET5_0_OR_GREATER | ||
| using var pooledHash = s_incrementalHashPool.GetPooledObject(); | ||
| Span<byte> buffer = stackalloc byte[SharedPools.ByteBufferSize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4K is a much larger buffer than we typically like to stackalloc. It might be fine for your scenarios, just calling it out. We have a rough guideline of not stackalloc'ing more than 1K.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Also, keep in mind this whole buffer will be zero'd unless you're using SkipLocalsInit.)
Glad it was helpful. Curious what the net impact looks like if there are any perf tests that surface it... |
Implements the changes suggested in #67995 (comment)
Review commit-by-commit highly recommended.
Supersedes #67998
Fixes #67995