-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix ascii range check #16535
Fix ascii range check #16535
Conversation
|
||
// in InvariantMode we support all range and not only the ascii characters. | ||
char maxChar = (char) (GlobalizationMode.Invariant ? 0xFFFF : 0x80); | ||
char maxChar = (char) (GlobalizationMode.Invariant ? 0xFFFF : 0x7f); |
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.
Is GlobalizationMode.Invariant
initrinsicish to the Jit? (like readonly static) and will it branch eliminate?
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.
should use _invariantMode and not GlobalizationMode.Invariant
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.
nit: Change 0x7f to 0x7F (all capital) to be consistent.
// _invariantMode is defined for the perf reason as accessing the instance field is faster than access the static property GlobalizationMode.Invariant | ||
// s_invariantMode is defined for the perf reason as accessing the field is faster than access the static property GlobalizationMode.Invariant | ||
[NonSerialized] | ||
private readonly bool _invariantMode = GlobalizationMode.Invariant; |
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.
GlobalizationMode.Invariat is a readonly static already. We do not need to duplicate it.
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.
This is cached in a instance field because instance field access is faster (in crossgened code in particular - and CoreLib is pretty much always crossgened).
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.
right, we just need to replace GlobalizationMode.Invariant with _invariantMode in CompareInfo code.
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.
All the instance methods already use it; other ones are static
{ | ||
{ | ||
// s_invariantMode is defined for the perf reason as accessing the field is faster than access the static property GlobalizationMode.Invariant | ||
private static readonly bool s_invariantMode = GlobalizationMode.Invariant; |
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.
See: #16379 (comment)
This cache does not make sense.
GlobalizationMode.Invariant
property should have the exact same perf as you local cache.
Can you also please update this comment?
Thanks for fixing this. |
5d1d349
to
5671023
Compare
5671023
to
be586ab
Compare
Addressed feedback |
Thanks @benaadams |
@dotnet-bot Tizen armel Cross Checked Innerloop Build and Test |
Won't let me rerun the Tizen |
|
||
// in InvariantMode we support all range and not only the ascii characters. | ||
char maxChar = (char) (GlobalizationMode.Invariant ? 0xFFFF : 0x80); | ||
char maxChar = (char) (GlobalizationMode.Invariant ? 0xFFFF : 0x7F); |
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.
Could this be computed just once in a static ctor? It's cheap, but this code is called a lot. (I can't see the context right now so this may be off.)
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.
@benaadams, thoughts?
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.
@jkotas pointed out it already is #16535 (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.
I was referring to the value, not GlobalizationMode. Ie put either 0xFFFF or 0x7F in a readonly static field. But seems unlikely that would be any faster than a conditional check each time here.
@dotnet-bot test Tizen armel Cross Checked Innerloop Build and Test |
Must have been some temporary issue. |
Sounds like we're also missing a test in corefx? |
@dotnet-bot test Windows_NT x64 Checked corefx_baseline |
Path failures
|
From Tizen armel Cross Checked Innerloop:
cc @AndyAyersMS |
|
@JeremyKuhne, @danmosemsft As an aside, this issue within the comments has been closed. Should it be removed? |
Yes, I think so, We may be missing a test case on the boundary between 0x7F and 0x80 where we aren't calling into the OS when we should. I wonder if the results are any different though. |
I though the plan was to decommission the Tizen tests as they are flaky. @RussKeldorph ?? |
@ahsonkhan, @benaadams Go ahead and disable the path test against me and I'll fix it asap- only |
Re: Tizen: The plan is to remove the emulator-based Tizen testing from default PR-triggers, due to the aforementioned flakiness, after we have reliable hardware-based ARM Linux testing in PR, which @BruceForstall is working on. |
@JeremyKuhne, does this PR resolve the failing tests were are seeing here, or do we still need to disable some tests? |
@dotnet-bot test Windows_NT x64 Checked corefx_baseline |
CI is passing (modulo Tizen), is this good to merge? |
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
cc @ahsonkhan @tarekgh, @jkotas