perf(parser): use memchr for lexing comments#8193
perf(parser): use memchr for lexing comments#8193MichaReiser merged 5 commits intoastral-sh:mainfrom sno2:main
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 |
| #[cfg(any( | ||
| target_arch = "x86_64", | ||
| target_arch = "aarch64", | ||
| target_arch = "wasm32" | ||
| ))] |
There was a problem hiding this comment.
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.
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 |
Summary
This might improve the performance of lexing. Not sure, though.
Test Plan
This was tested using the existing tests.