-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Refactor known folder GUIDs to use static properties #118165
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
…ants internal const string ([a-z0-9]+) = "\{([a-z0-9]{8})-([a-z0-9]{4})-([a-z0-9]{4})-([a-z0-9]{2})([a-z0-9]{2})-([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})\}"; internal static Guid $1 => new(0x$2, 0x$3, 0x$4, 0x$5, 0x$6, 0x$7, 0x$8, 0x$9, 0x$10, 0x$11, 0x$12);
2a9ad80
to
77f5d77
Compare
Is this expected to be a perf improvement? Do you have any numbers (for the public Environment APIs) to demonstrate that this is better? |
This comment has been minimized.
This comment has been minimized.
This was expected to be a performance improvement as it avoids the overhead of initialising a Guid from a string, see https://csharp.godbolt.org/z/vxKqKjT4r However |
How about code size metrics? Is this a binary size improvement, e.g. for NAOT? |
@EgorBo Could you help verify this? |
@MihaZupan These changes are specific to Windows target, is this an option with MihuBot? |
This comment was marked as outdated.
This comment was marked as outdated.
No, hasn't been wired through for the JIT diffs |
1kb is not that much and it is 4kB regression for non-NAOT ( Have you tried to actually step through the code to see where to make this better? I see:
|
src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs
Outdated
Show resolved
Hide resolved
This comment was marked as outdated.
This comment was marked as outdated.
I do not expect that this ReadOnlySpan change is going improve throughput over the previous version. It is code size improvement. You may see some throughput improvement if you get rid of Enum.IsDefined calls. |
src/libraries/System.Private.CoreLib/src/System/Environment.Win32.cs
Outdated
Show resolved
Hide resolved
…n32.cs Co-authored-by: Jan Kotas <[email protected]>
This comment has been minimized.
This comment has been minimized.
src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs
Show resolved
Hide resolved
@EgorBo There is no correctness issue for big-endian platforms, since we call Guid(ReadOnlySpan). Using |
4kb-5kB improvement for NAOT MichalStrehovsky/rt-sz#159 (comment) |
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
The following regular expression was used:
internal const string ([a-z0-9]+) = "\{([a-z0-9]{8})-([a-z0-9]{4})-([a-z0-9]{4})-([a-z0-9]{2})([a-z0-9]{2})-([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})\}";
internal static Guid $1 => new(0x$2, 0x$3, 0x$4, 0x$5, 0x$6, 0x$7, 0x$8, 0x$9, 0x$10, 0x$11, 0x$12);