Skip to content
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

[wasm] Fast-track ASCII/UTF8 conversion in wasm #51310

Closed

Conversation

radekdoulik
Copy link
Member

No description provided.

@radekdoulik radekdoulik added the arch-wasm WebAssembly architecture label Apr 15, 2021
@ghost
Copy link

ghost commented Apr 15, 2021

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details
Author: radekdoulik
Assignees: -
Labels:

arch-wasm

Milestone: -

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@@ -19,8 +19,10 @@ public static OperationStatus TranscodeToUtf16(byte* pInputBuffer, int inputLeng
Debug.Assert(outputCharsRemaining >= 0, "Destination length must not be negative.");
Debug.Assert(pOutputBuffer != null || outputCharsRemaining == 0, "Destination length must be zero if destination buffer pointer is null.");

var input = new ReadOnlySpan<byte>(pInputBuffer, inputLength);
var output = new Span<char>(pOutputBuffer, outputCharsRemaining);
// try fast-tracking ASCII first before falling back to the standard loop
Copy link
Member

@jkotas jkotas Apr 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that this is going to fully fix the regression for ASCII-only payloads. The regression is still going to be there to varying degress once the payload contains non-ASCII characters. What do the perf numbers look like for non-ASCII payloads?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we marked Rune.DecodeUtf8 and Rune.DecodeUtf16 as aggressive-inlining, at least on wasm? Those methods each have some amount of error handling logic, where they'll try to figure out how to recover from any invalid data. But these immediate callers don't care about recovering from invalid data. These callers simply want to halt when invalid data is encountered. If we inline those methods, in theory the error recovery logic should be elided because it triggers the if (not success) { break; } block. That might result in a perf improvement, but I don't know offhand what such an improvement might look like.

@radekdoulik
Copy link
Member Author

Closing this draft as we are going to revert the previous change for P4 (#51379)

@ghost ghost locked as resolved and limited conversation to collaborators May 16, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants