-
Notifications
You must be signed in to change notification settings - Fork 5.4k
More Sway compiler optimizations #7093
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
Conversation
9c37556
to
103a146
Compare
CodSpeed Performance ReportMerging #7093 will improve performances by ×140Comparing Summary
Benchmarks breakdown
|
70210d0
to
54c0454
Compare
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.
This is really neat. Amazing performance increase. Hats off!
Crazy speedup, amazing 🚀 Just to note that "compile" and "did_change_with_caching" steps on LSP benchmark seem to have gotten around 7-9% slower though, seems unlikely to have been caused by the changes though given the speedups? |
b0109be
to
f33b676
Compare
I also managed to optimize "did_change_with_caching". |
Description
This PR is a prequel to #7015, trying to optimize the compiler to alleviate the hit of having more items,
impl
etc...We have here two optimizations:
1 - We spend a lot of time counting newlines when converting byte offsets to
LineCol
. Now, we calculate line offsets just once, and use binary search later to find which line a byte offset is at.2 -
QueryEngine::get_programs_cache_entry
was cloning the wholeTyProgram
. That is whydid_change_with_caching
was always getting worse, as the program was increasing in size. Now all compilation stages are behindArc
, which makes theclone
free.Analysis
Putting a
dbg!(...)
like the image below, and callingcounts
(https://github.com/nnethercote/counts).I get the following results:
This means that
line_col
is being called 972k times. 16% is for position zero, which should be trivial. The rest will iterate the whole file source code to count number of lines. Making the real complexity of the work here something likeO(qty * self.pos)
. And some values ofself.pos
are not trivial at all.Checklist
Breaking*
orNew Feature
labels where relevant.