174 Commits

Author SHA1 Message Date
Chayim Refael Friedman
6315e315ad Expand target info to include the architecture
And make it easier to expand it more in the future, if needed.
2025-09-09 13:47:26 +03:00
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
Shoyu Vanilla
15ac6a21dd fix: Make lang items query properly filter out overwritten/excluded sysroots 2025-08-17 22:28:04 +09:00
Chayim Refael Friedman
74ecb1e788 When renaming a parameter to self, change callers to use method call syntax 2025-08-02 21:39:22 +03:00
Lukas Wirth
6b09fbf881 fix: Consider all produced artifacts for proc-macro dylib search 2025-07-27 23:21:42 +02:00
Lukas Wirth
7950da3940 internal: Better type proc macro dylib build data state 2025-07-27 19:37:16 +02:00
Lukas Wirth
8029c731ed Bump salsa 2025-07-03 10:05:16 +02:00
Lukas Wirth
e54759083a Restructure proc-macro loading erros, differentiate hard error property on kind 2025-07-03 09:28:53 +02:00
Lukas Wirth
13494f4cac ItemTree's ItemVisibilities has no identity, so deduplicate 2025-06-12 09:14:43 +02:00
Lukas Wirth
cbff4ae151 Bump salsa 2025-05-23 12:58:00 +02:00
Chayim Refael Friedman
56fb415ba7 Don't allow duplicate crates in the all_crates list
For some reason we had them in some projects, I'm not sure why. But this caused cache priming to appear stuck - because it uses a set of crate IDs for the actual work, but for the number of crates to index it just uses `db.all_crates().len()`.
2025-05-14 21:38:40 +03:00
Lukas Wirth
62e7e2b489 chore: Adjust panic context printing 2025-04-30 07:40:11 +02:00
Lukas Wirth
996d6ed1a3 Split out salsa_macros
Does not do much yet due to tracing pulling syn but oh well
2025-04-29 19:43:36 +02:00
Lukas Wirth
9fa647c129 Update salsa 2025-04-29 19:26:19 +02:00
David Barsky
9e3bbd8acc base-db: add more details to panic 2025-04-28 13:30:33 -07:00
Chayim Refael Friedman
1fe060719a shrink_to_fit() in more places
This saves 18mb on `analysis-stats .`, without regressing speed.
2025-04-25 10:55:12 +03:00
Chayim Refael Friedman
2bba385dda Adjust for new Salsa not implementing Debug by default 2025-04-22 15:19:35 +03:00
Chayim Refael Friedman
c58ddafe90 Make HirFileId, EditionedFileId and macro files Salsa struct
And make more queries non-interned.

Also flip the default for queries, now the default is to not intern and to intern a query you need to say `invoke_interned`.
2025-04-19 22:10:52 +03:00
Chayim Refael Friedman
8a9a1e3345 Remove all upcasts!
It turns out there were a lot redundant too.
2025-04-10 11:08:38 +03:00
Lukas Wirth
e7ce86ddea fix: Fix format_args lowering for >=1.87 2025-04-06 10:05:56 +02:00
BenjaminBrienen
2462624a7d prefer default over new 2025-04-04 15:49:50 +02:00
Lukas Wirth
1c7f253ec9 chore: Remove unnecessary Arc clones 2025-04-01 13:18:37 +02:00
Lukas Wirth
faf1b49a9a fix: Fix, clarify and require a value for proc_macro_cwd of CrateData 2025-03-29 08:08:48 +01:00
Lukas Wirth
454e4be40d refactor: Use MEDIUM durability for crate-graph changes, high for library source files
The idea here is that the crate graph may change over time, but library source file contents *never* will (or really never should). Disconnecting the two means that queries that depend on library sources will not need to re-validatewhen the crate graph changes (unless they depend on the crate graph in some capacity).
2025-03-26 06:46:49 +01:00
Lukas Wirth
b5eedad8e3 refactor: Remove unnecessary Arc 2025-03-16 10:27:48 +01:00
Lukas Wirth
7edfeb9674 refactor: Remove CrateGraphBuilder::iter_mut 2025-03-16 10:24:15 +01:00
BenjaminBrienen
7535bb4661 cargo fmt 2025-03-15 21:32:01 +01:00
Lukas Wirth
db4ba3a991
Merge pull request #19364 from Veykril/push-uonyorwwzpzx
fix: Fix missing `with_durability` calls
2025-03-15 15:09:18 +00:00
Lukas Wirth
f19c416d45 fix: Fix missing with_durability calls 2025-03-15 15:53:23 +01:00
Florian Diebold
c1102ac703 Avoid recursively debug printing crates 2025-03-14 19:02:06 +01:00
David Barsky
788232b355 internal: don't panic when the crate graph isn't ready #19351 2025-03-13 15:14:08 -04:00
Chayim Refael Friedman
c94e9efbef Salsify the crate graph
I.e. make it not one giant input but multiple, for incrementality and decreased memory usage for Salsa 3 reasons.
2025-03-12 21:02:30 +02:00
David Barsky
74620e64ec internal: port rust-analyzer to new Salsa 2025-03-10 13:30:51 -04:00
Mehul Arora
3a31741627 Use correct working directory for non-workspace proc-macro execution 2025-02-17 10:36:32 -05:00
Lukas Wirth
ab5e821d97 Expose symbol of CrateName 2025-02-04 14:38:58 +01:00
Wilfred Hughes
7f6b8745c8 minor: Fix grammar in doc comments
"too" should be "to" here.
2025-01-10 17:38:14 -08:00
lucasholten
cdc972499e Automatically sort crate graph 2025-01-02 15:50:51 +01:00
lucasholten
947dfdce0c Add back optimizations 2024-12-31 15:48:58 +01:00
lucasholten
6043412342 Add back crate graph deduplication 2024-12-31 15:47:29 +01:00
Lukas Wirth
7085328185 Remove patch sysroot cfg-if hack 2024-12-09 11:42:51 +01:00
David Barsky
ccee36e8dd chore: rename salsa to ra_salsa 2024-10-14 10:09:22 -04:00
Lukas Wirth
f7ca085690 Remove ImportSource::ExternCrate as the fixed point loop can't affect it 2024-10-05 15:02:47 +02:00
Lukas Wirth
db04f514f2 Lift out workspace related data into a separate query to preserve crategraph deduplication 2024-09-11 12:16:41 +02:00
Lukas Wirth
8905f86d8a Remove crate graph deduplication logic 2024-09-11 11:38:42 +02:00
Lukas Wirth
2e2f798a74 minor: Downgrade cyclic deps error to warning 2024-09-01 10:02:41 +02:00
Lukas Wirth
fa48bc216c
Revert "feat: Implement module_path macro" 2024-08-27 08:19:09 +02:00
Lukas Wirth
d44a3ab30c internal: Implement module_path macro 2024-08-21 13:50:05 +02:00
Lukas Wirth
d2fe906a62 Remove unnecessary CfgFlag definition in project-model 2024-08-07 14:27:59 +02:00
Lukas Wirth
188c577855 Newtype ErasedFileAstId 2024-08-05 13:46:47 +02:00
Lukas Wirth
fcb88832de Simplify FileDelegate 2024-08-05 13:03:03 +02:00