-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustdoc-search: optimize unifyFunctionTypes #118024
Conversation
Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @jsha |
b436a38
to
5de7521
Compare
This is a major source of expense on generic queries, and this commit reduces them. Profile output: https://notriddle.com/rustdoc-html-demo-5/profile-2/index.html
Short queries, in addition to being common, are also the base case for a lot of more complicated queries. We can avoid most of the backtracking data structures, and use simple recursive matching instead, by special casing them. Profile output: https://notriddle.com/rustdoc-html-demo-5/profile-3/index.html
5de7521
to
a66972d
Compare
That's great, thanks a lot! @bors r+ rollup |
@bors r- One more commit that I came up with while waiting for the review. Sorry for the noise! |
Again, sorry about the noise. Here's the last commit, which switches from using a
|
This is significantly faster, because - It allows the one-element fast path to kick in on multi- element queries. - It constructs intermediate data structures more lazily than the old system did. It's measurably faster than the old algo even without the fast path, but that fast path still helps significantly.
4d5bfe8
to
d82b374
Compare
New changes look good to me. Big question though: would it be possible to include your benchmark in the rust performance tool? I think it's becoming quite an important topic to have good performance when performing a search. In any case, thanks for this PR! @bors r+ rollup |
☀️ Test successful - checks-actions |
Finished benchmarking commit (27794f9): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 676.326s -> 676.664s (0.05%) |
Final profile output:
https://notriddle.com/rustdoc-html-demo-5/profile-4/index.html
This PR contains three commits that improve performance of this hot inner loop: reduces the number of allocations, a fast path for the 1-element basic query case, and reconstructing the multi-element query case to use recursion instead of an explicit
backtracking
array. It also adds new test cases that I found while working on this.r? @GuillaumeGomez