-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
perf(parser): use memchr for lexing comments #8193
Conversation
We now use memchr on its SIMD-supported targets to improve the performance of lexing comments.
PR Check ResultsEcosystem✅ ecosystem check detected no changes. |
Improvements seem neglible: https://codspeed.io/astral-sh/ruff/branches/sno2:main |
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.
It gives us a small speed up for the lexer. I didn't expect parsing to improve, because it performs way too many allocations. However, this could speed up things once we improve our parser.
#[cfg(any( | ||
target_arch = "x86_64", | ||
target_arch = "aarch64", | ||
target_arch = "wasm32" | ||
))] |
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 think memchr
handl this automatically and not having the configuration ensures that newly supported platforms automatically profit from a faster memchr
routine.
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.
True, will look into this more.
CodSpeed Performance ReportMerging #8193 will not alter performanceComparing Summary
|
This might improve performance here because we do not compare comments to values that often. Therefore, the memory locality might improve performance in certain cases as well.
Using compact_str does not seem to be faster for us :(
I've given up on trying to optimize the String creation so this is ready for review :^) It seems that the only way we could get a performance boost from comment string allocation in the lexer is to not do it at all and use lifetimes and |
I once had a pr that used |
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.
Thank you :)
Summary
This might improve the performance of lexing. Not sure, though.
Test Plan
This was tested using the existing tests.