Optimize the initialization of the OrdinalCasing::s_sCasingTable table.#46061
Optimize the initialization of the OrdinalCasing::s_sCasingTable table.#46061tarekgh merged 6 commits intodotnet:masterfrom
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))); |
src/libraries/System.Private.CoreLib/src/System/Globalization/OrdinalCasing.Icu.cs
Outdated
Show resolved
Hide resolved
tarekgh
left a comment
There was a problem hiding this comment.
@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.