-
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
[browser][non-icu] HybridGlobalization
support interning
#84695
Conversation
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsSuggested in comment. For performance reasons it pays off to exchange char*+lenght to string when passing data from managed code to JS.
|
{ | ||
cmpResult = Interop.JsGlobalization.CompareString(out exceptionMessage, cultureName, pString1, string1.Length, pString2, string2.Length, options); | ||
} | ||
int cmpResult = Interop.JsGlobalization.CompareString(out exceptionMessage, cultureName, span1.ToString(), span2.ToString(), options); |
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.
Isn't this going to allocate temporary C# strings in order to pass them to JS? This will break interning too.
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 am not sure how to do it differently, if we want to operate on strings we need to at least allocate a local string in the function. We cannot change the fact that arguments enter in a form of ReadOnlySpan<char>
and it looks like span, passing the C#/JS border is treated the same way as char*.
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 guess we have speed vs (icu data) size tradeoff here. If they choose hybrid, they would get size, but not speed.
Seems OK to me if the perf is around %200.
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.
In the past mesurements on normalization function it was more than that, around 500%. It is a good idea to start measuring how HG does in comparison to ICU4C.
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 am not sure how to do it differently, if we want to operate on strings we need to at least allocate a local string in the function. We cannot change the fact that arguments enter in a form of
ReadOnlySpan<char>
and it looks like span, passing the C#/JS border is treated the same way as char*.
In that case for this the way you did it previously (passing pointers) is the only reasonable way, making a temp C#/MonoString is not going to help.
Closing after investigating all possible solutions. See - discussion above |
Suggested in comment. For performance reasons it pays off to exchange char*+lenght to string when passing data from managed code to JS.
HybridGlobalization
change case #84019 we are passing only culture-sensitiveabc....xyz
string and that does not contain repetitive literals, we do not need to change the original implementation there.HybridGlobalization
compare #84249, the mechanism described by @kg can be beneficial. We are changing the implementation forComparison
.