rust-analyzer/crates
Chayim Refael Friedman 1c8a07cfd6 Cache trait solving across queries in the same revision
Caching trait solving can do a lot to speed. Unfortunately it also consume a huge amount of memory. Therefore, as part of the migration to the new solver Jack Huey disabled caching of trait solving (he made the query transparent).

The PR proposes a middle ground: do cache trait solving, but only for the same revision. This allows us to be safe because during a revision the inputs cannot change.

The result is hopefully much better performance to features that tend to do a bulk of trait solving, and also repeat the same query (e.g. inference then IDE features).

There is another limitation: results are only cached in the same thread, to remove the need for synchronization which will be expensive. More measurements are required to check whether it's better to use a synchronized global cache, or maybe stay with a thread-local cache but batch multiple feature requests (highlighting, inlay hints etc.) of the same file to the same thread.

Alongside the actual cache we store the revision, because we need to verify it (we can't eagerly clear caches when incrementing the revision), and also the address of the db to prevent multiple dbs from interleaving (this is mostly relevant in tests, although injected highlighting also uses a new db, therefore maybe it's better to move it to a separate thread).

This "games" analysis-stats to both be way faster and use way more memory; the former is because analysis-stats doesn't increment revisions, therefore all queries share the cache and hit ratio is way too good, the latter is because analysis-stats doesn't increment revisions and therefore the cache isn't cleared. Both are not representative of a typical IDE scenario.
2025-08-25 17:17:31 +03:00
..
base-db Cache trait solving across queries in the same revision 2025-08-25 17:17:31 +03:00
cfg cargo clippy --fix 2025-07-31 10:55:10 +02:00
edition
hir Merge pull request #20442 from ChayimFriedman2/unqualify 2025-08-18 06:24:35 +00:00
hir-def Cache trait solving across queries in the same revision 2025-08-25 17:17:31 +03:00
hir-expand When renaming a parameter to self, change callers to use method call syntax 2025-08-02 21:39:22 +03:00
hir-ty Cache trait solving across queries in the same revision 2025-08-25 17:17:31 +03:00
ide Fix panic in syntax_highlighting 2025-08-22 09:00:25 +02:00
ide-assists user facing code should use not use PostAnalysis 2025-08-19 08:24:34 +02:00
ide-completion Auto-attach database in Analysis calls 2025-08-18 09:52:23 +02:00
ide-db Cache trait solving across queries in the same revision 2025-08-25 17:17:31 +03:00
ide-diagnostics Auto-attach database in Analysis calls 2025-08-18 09:52:23 +02:00
ide-ssr Implement next trait solver 2025-08-09 16:08:58 +00:00
intern Implement next trait solver 2025-08-09 16:08:58 +00:00
load-cargo cargo clippy --fix 2025-07-31 10:55:10 +02:00
mbe cargo clippy --fix 2025-07-31 10:55:10 +02:00
parser Auto-attach database in Analysis calls 2025-08-18 09:52:23 +02:00
paths Don't run doctests 2025-06-23 00:50:22 +03:00
proc-macro-api Add version command to proc-macro-srv 2025-07-31 10:10:50 +02:00
proc-macro-srv Reorganize proc-macro-srv 2025-07-31 09:55:07 +02:00
proc-macro-srv-cli Add version command to proc-macro-srv 2025-07-31 10:10:50 +02:00
profile Implement next trait solver 2025-08-09 16:08:58 +00:00
project-model remove duplicate field in Debug 2025-08-08 23:46:28 +02:00
query-group-macro Implement next trait solver 2025-08-09 16:08:58 +00:00
rust-analyzer Deduplicate layout_of_adt 2025-08-17 16:04:50 +00:00
span Merge Trait and TraitAlias handling 2025-08-13 15:28:08 +08:00
stdx Don't run doctests 2025-06-23 00:50:22 +03:00
syntax Merge Trait and TraitAlias handling 2025-08-13 15:28:08 +08:00
syntax-bridge remove P 2025-08-09 15:47:01 +08:00
test-fixture fix: Make lang items query properly filter out overwritten/excluded sysroots 2025-08-17 22:28:04 +09:00
test-utils Merge pull request #20329 from jackh726/next-trait-solver-querify 2025-08-13 06:10:45 +00:00
toolchain Don't run doctests 2025-06-23 00:50:22 +03:00
tt cargo clippy --fix 2025-07-31 10:55:10 +02:00
vfs Bump salsa 2025-07-03 10:05:16 +02:00
vfs-notify cargo clippy --fix 2025-07-31 10:55:10 +02:00