-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Extra null check on as_bytes() iteration with break #25306
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
Comments
cc @huonw |
Triage: today, this seems much better:
The other two functions actually look worse, but I am not an expert here. @raphlinus what do you think? |
Yeah, all good today. I haven't done deep performance analysis, but from examination of the assembly code they all look good. There is a slight difference, in the first version the check against This function will become less important in the rewrite of pulldown-cmark. I'm toying with ideas to use SIMD to find "exceptional" bytes in the input, similar to bytecount. |
Because the loop in |
@raphlinus perhaps https://github.com/shepmaster/jetscii would be of interest then. |
Code generation is less than ideal for a function which iterates over a string as_bytes() and has a break; there is a null check of the pointer to the bytes before loading.
Here's the function and the asm:
The function and two other versions (which generate better code) are at http://is.gd/E4i7z7. A version which uses enumerate doesn't have the null check, but has an extra movq. A version which uses position rather than writing the loop generates perfect code. Just for context, this issue arose while writing a Markdown parser. The current code uses position(), and the speedup was significant.
The text was updated successfully, but these errors were encountered: