9db1258dbe
Fix OOM caused by term search The issue came from multi Cartesian product for exprs with many (25+) arguments, each having multiple options. The solution is two fold: ### Avoid blowing up in Cartesian product **Before the logic was:** 1. Find expressions for each argument/param - there may be many 2. Take the Cartesian product (which blows up in some cases) 4. If there are more than 2 options throw them away by squashing them to `Many` **Now the logic is:** 1. Find expressions for each argument/param and squash them to `Many` if there are more than 2 as otherwise we are guaranteed to also have more than 2 after taking the product which means squashing them anyway. 2. Take the Cartesian product on iterator 3. Start consuming it one by one 4. If there are more than 2 options throw them away by squashing them to `Many` (same as before) This is also why I had to update some tests as the expressions get squashed to many more eagerly. ### Use fuel to avoid long search times and high memory usage Now all the tactics use `should_continue: Fn() -> bool` to chech if they should keep iterating _(Similarly to chalk)_. This reduces the search times by a magnitude, for example from ~139ms/hole to ~14ms/hole for `ripgrep` crate. There are slightly less expressions found, but I think speed gain worth it for usability. Also note that syntactic hits decreases more because of squashing so you simple need to run search multiple times to get full terms. Also the worst case time (For example `nalgebra` crate cus it has tons of generics) has search times mostly under 200ms. Benchmarks on `ripgrep` crate Before: ``` Tail Expr syntactic hits: 291/1692 (17%) Tail Exprs found: 1253/1692 (74%) Term search avg time: 139ms ```` After: ``` Tail Expr syntactic hits: 239/1692 (14%) Tail Exprs found: 1226/1692 (72%) Term search avg time: 14ms ``` |
||
---|---|---|
.cargo | ||
.github | ||
.vscode | ||
assets | ||
bench_data | ||
crates | ||
docs | ||
editors/code | ||
lib | ||
xtask | ||
.editorconfig | ||
.git-blame-ignore-revs | ||
.gitattributes | ||
.gitignore | ||
.typos.toml | ||
Cargo.lock | ||
Cargo.toml | ||
clippy.toml | ||
CONTRIBUTING.md | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
PRIVACY.md | ||
README.md | ||
rust-bors.toml | ||
rust-version | ||
rustfmt.toml | ||
triagebot.toml |
rust-analyzer is a modular compiler frontend for the Rust language. It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust.
Quick Start
https://rust-analyzer.github.io/manual.html#installation
Documentation
If you want to contribute to rust-analyzer check out the CONTRIBUTING.md or if you are just curious about how things work under the hood, check the ./docs/dev folder.
If you want to use rust-analyzer's language server with your editor of choice, check the manual folder. It also contains some tips & tricks to help you be more productive when using rust-analyzer.
Security and Privacy
See the corresponding sections of the manual.
Communication
For usage and troubleshooting requests, please use "IDEs and Editors" category of the Rust forum:
https://users.rust-lang.org/c/ide/14
For questions about development and implementation, join rust-analyzer working group on Zulip:
https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer
Quick Links
- Website: https://rust-analyzer.github.io/
- Metrics: https://rust-analyzer.github.io/metrics/
- API docs: https://rust-lang.github.io/rust-analyzer/ide/
- Changelog: https://rust-analyzer.github.io/thisweek
License
rust-analyzer is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.