-
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
Optimize the initialization of the OrdinalCasing::s_sCasingTable table. #46061
Conversation
The table was initialized in the .cctor and it contains a large amount of object references, so the generated cctor was 1K IL. Replace with a byte table and a loop. Fixes dotnet#43732.
Tagging subscribers to this area: @tarekgh, @safern, @krwq Issue DetailsThe table was initialized in the .cctor and it contains a large amount of object references, so the generated cctor was Fixes #43732.
|
src/libraries/System.Private.CoreLib/src/System/Globalization/OrdinalCasing.Icu.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Globalization/OrdinalCasing.Icu.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Globalization/OrdinalCasing.Icu.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Globalization/OrdinalCasing.Icu.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Globalization/OrdinalCasing.Icu.cs
Outdated
Show resolved
Hide resolved
Updated based on comments. |
src/libraries/System.Private.CoreLib/src/System/Globalization/OrdinalCasing.Icu.cs
Show resolved
Hide resolved
@vargaz could you please have some perf benchmark numbers before and after your changes? just to ensure there is no perf effect? |
src/libraries/System.Private.CoreLib/src/System/Globalization/OrdinalCasing.Icu.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Globalization/OrdinalCasing.Icu.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Globalization/OrdinalCasing.Icu.cs
Show resolved
Hide resolved
for (int i = 0; i < s_casingTableInit.Length * 8; ++i) | ||
{ | ||
// The bits are in reverse order | ||
byte val = (byte)(s_casingTableInit[i / 8] >> (7 - (i % 8))); |
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.
make 8 a local const?
src/libraries/System.Private.CoreLib/src/System/Globalization/OrdinalCasing.Icu.cs
Outdated
Show resolved
Hide resolved
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.
@vargaz thanks for getting this fix.
I am approving it but would be good if you can include some benchmark numbers before and after the change. I am not expecting any perf regression but I want to ensure nothing will surprise us.
Will try, just have trouble running the benchmarks. |
Which public api ends up in this code path ? |
I don't think there is much to be measured, you changed a code which is called once. |
The table was initialized in the .cctor and it contains a large amount of object references, so the generated cctor was
1K IL. Replace with a byte table and a loop.
Fixes #43732.