ruff
0ff46ebe - [ty] Collect completions into a max-heap

Commit
18 days ago
[ty] Collect completions into a max-heap The previous commits made this change deliciously simple. The key point is that we don't collect a completion if it has no way of being ranked into the top 1000 that we return. Before: ``` $ ./target/profiling/ty_completion_bench ~/astral/relatedclones/scratch-home-assistant/homeassistant/scratch.py 1 -q --iters 30 total elapsed for initial completions request: 554.746713ms total elapsed: 5.435318983s, time per completion request: 181.177299ms After: ``` $ ./target/profiling/ty_completion_bench ~/astral/relatedclones/scratch-home-assistant/homeassistant/scratch.py 1 -q --iters 30 total elapsed for initial completions request: 526.743638ms total elapsed: 4.268009725s, time per completion request: 142.26699ms ``` This is an especially nice speed-up for the cached case, where lots of time (proportionally) was being spent sorting potentially a very large list of completions. There is potential future wins here. For example, every auto-import completion has an `import` statement generated for it. We could instead defer to that work until the very end when we convert the max-heap into a `Vec`. Since before then, the completion might get dropped and there's no point in doing extra work. But that will require more refactoring (and possibly another `CompletionIntermediate` type? blech).
Author
Committer
Parents
Loading