-
Notifications
You must be signed in to change notification settings - Fork 63
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
Performance suggestion: reduce allocations #21
Comments
Performance is important because even for a pretty complex linter parsing consumes about 80% of overall time which is not really what I would like to get :). |
Changes in that files reduce memory allocations in five times, especially Also, I see you disable saving comments, I have created issue #22, it increases speed when comments unnecessary. |
There are a lot of allocations done in strings.TrimLeft as well as it creates new temporary function every time: https://golang.org/src/strings/strings.go?s=20503:20548#L785 You can use strings.TrimPrefix though, it probably will be faster too: https://golang.org/src/strings/strings.go?s=21232:21272#L809 |
I really want to have some generic approach of grouping allocations for all AST nodes, not just for most popular ones (as I did). It will give huge performance boost and (probably) reduce consumed memory too. I am not sure how to implement it properly in this project so I just created this issue to discuss possible solutions if you are interested :). |
788628d reduces allocations from 10405 to 7430 in benchmark and reduces cpu usage by |
#21 scanner.Lexer.charsToBytes optimization
By using |
The parser is not as performant as it could be (PHP7+ also creates AST in order to execute file):
test.go.zip
I made a few (very hacky) patches that significantly reduce allocations count for some critical parts and it reduced parsing time by a factor of 1.5:
There are still plenty more allocations that profiler shows, my patches are just proof-of-concept.
speedup.patch.txt
The text was updated successfully, but these errors were encountered: