-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Disable optimization which sometimes results in incorrect case sensitivity in FrozenCollections #94667
Disable optimization which sometimes results in incorrect case sensitivity in FrozenCollections #94667
Conversation
…hould be the same
Tagging subscribers to this area: @dotnet/area-system-collections Issue DetailsSee #93986 for full context
|
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/KeyAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/KeyAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/KeyAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/tests/Frozen/FrozenFromKnownValuesTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System.Collections.Immutable.csproj
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.
To get a feel of potential perf regressions, would it be possible to share benchmarks comparing this to main
in the impacted cases?
@eiriktsarpalis That would require a PR in the performance repo. Is it possible for somebody from the MS team to do that as I am pretty busy. If not I'll try find some time. |
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. Do we have an understanding of what uses this might regress and by how much? We should make the change, regardless, but I'd like to understand the ramifications and what we should be looking at following-up on.
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/KeyAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/KeyAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/KeyAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/KeyAnalyzer.cs
Outdated
Show resolved
Hide resolved
c44f0a1
to
c45a592
Compare
Removing the optimization will be a regression (haven't got a measurement*) only in the case where we are case insensitive, have identified a partial substring to hash, and that substring contains no letters. In all other cases it matches .NET 8 release.
Perf benchmarks in #93986 (comment) show that for case sensitive there is no effect. However that doesn't answer your question as this particular optimization being disabled was never benchmarked by the performance repo. If I find time to add a benchmark I'll add it here but I don't foresee having the time before the weekend. |
Ok, thanks. As noted, we don't need to block on it. @eiriktsarpalis, if you have some time to get some quick numbers just to aid in our understanding of the impact and whether there's an important follow-up here, that'd be helpful. |
I tweaked the
In certain cases performance becomes up to 2x slower, but this impacts cases where lookup is currently incorrect. |
@andrewjsaid there seem to be a few failing unit tests from KeyAnalyzer. |
@eiriktsarpalis there's 2 parts to the reduced performance. As the bug is causing us to use case sensitive comparison it's artificially faster than any correct version of the code thus it's not a fair comparison. The second part is the cost of removing this optimization which boils down to case sensitivity of a a partial substring of up to 8 chars. To measure that change we can benchmark with #93986 which has a much larger diff but keeps the optimization. |
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
Thank you for the help @andrewjsaid! |
/backport to release/8.0 |
Started backporting to release/8.0: https://github.com/dotnet/runtime/actions/runs/6856200961 |
@eiriktsarpalis backporting to release/8.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Add failing tests
Applying: Fix incorrect case sensitivity in FrozenDictionary and FrozenSet for some cases
Applying: When hashing the entire string, case sensitivity of hash and equals should be the same
Applying: Address code review comments
Applying: Only ignore case insensitivity if entire string is ASCII non-letters
error: sha1 information is lacking or useless (src/libraries/System.Collections.Immutable/src/System.Collections.Immutable.csproj).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0005 Only ignore case insensitivity if entire string is ASCII non-letters
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
@eiriktsarpalis an error occurred while backporting to release/8.0, please check the run log for details! Error: git am failed, most likely due to a merge conflict. |
Pleased to be of help! |
…ivity in FrozenCollections (dotnet#94667) * Add failing tests * Fix incorrect case sensitivity in FrozenDictionary and FrozenSet for some cases fixes dotnet#93974 * When hashing the entire string, case sensitivity of hash and equals should be the same * Address code review comments * Only ignore case insensitivity if entire string is ASCII non-letters * Code review comments * Undo some new lines * Fixed tests - incorrect leftover from previous PR
…ivity in FrozenCollections (#94667) (#94685) * Add failing tests * Fix incorrect case sensitivity in FrozenDictionary and FrozenSet for some cases fixes #93974 * When hashing the entire string, case sensitivity of hash and equals should be the same * Address code review comments * Only ignore case insensitivity if entire string is ASCII non-letters * Code review comments * Undo some new lines * Fixed tests - incorrect leftover from previous PR Co-authored-by: Andrew J Said <[email protected]>
See #93986 for full context
Fix #93974