-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Remove char[] allocations from RegistryKey and List copy to Array #78558
Conversation
Tagging subscribers to this area: @dotnet/area-microsoft-win32 Issue DetailsReplace char[] allocation with stackalloc memory (no need to rent for 256 chars)
|
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.
Thanks. Can you share a perf test with numbers?
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.Windows.cs
Outdated
Show resolved
Hide resolved
Here are the statistics based on enumerate HKCR/CLSID (11128 entries on my computer), there's a 6,3% gain on allocation. BenchmarkDotNet=v0.13.2, OS=Windows 10 (10.0.19044.2130/21H2/November2021Update)
// * Hints * |
Partially overlaps with #77996. |
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.
Thanks.
6e3e6ae
to
3d4f512
Compare
Replace char[] allocation with stackalloc memory (no need to rent for 256 chars)
Replace List by string[] to avoid List.ToArray() copy (it must handle rare cases where there are more or less elements during the loop).
Avoid redondant verification EnsureNotDisposed() already called by SubKeyCount & ValueCount.