Conversation
|
does this fix #23091 ? |
|
See #t-compiler/rust-analyzer > autoderef / solver recursion limits. This is not something to be done lightly. |
Previously we had a recursion limit of 50 in the next_solver logic, which didn't match rustc. This prevents us generating SCIP files for some crates, and presumably would also stop r-a accepting code that rustc accepted. For example, the `element-hq/matrix-authentication-service` GitHub project at commit 8a6751398d7e9ea5cf28d48992bae99541431cd6. AI disclosure: Code was partly written by Opus 5, but comments, commit message and review by me.
ade2a31 to
806761e
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Regarding performance impact of these changes: rustc runs twice, once with a recursion limit of 128 (unless overridden), and then again with 2x the recursion limit to emit a future compatibility warning (added in rust-lang/rust#159224). So this felt relatively conservative. I've built SCIP for a ton of internal crates at work, external crates they depend on, and large number of GitHub Rust repos for other projects, and only seen the old limit hit in three cases (the The two tests needing a bigger stack nearly fit in the libtest default (2 MiB I think), it's only around recursion limit ~100 that they start hitting the stack limit (I don't have the original terminal session, I can measure exactly if it's useful). So maybe a value of 128 isn't too crazy? I don't see any benchmarks mentioned on #20329 when the value of 50 was chosen, do you have any thoughts on how to collect more performance data? Alternatively, considering this now brings us to parity with rustc, how much of a slowdown would we tolerate? |
|
I understand the performance concern (and wanting to know the impact with broken macros), but I think not matching rustc is a lot worse. |
|
Impact on correct code is important but impact on incorrect code is more problematic. See the linked Zulip where I described the possible problems. |
|
OK, I've done a bit of benchmarking. The code snippet in the Zulip thread is specifically about autoderef, which seems to have its own recursion limit and isn't affected by the change here. I took the code snippet in The LSP timings were: This isn't a perfect benchmark, because the hover information gets progressively more I ran this on my M4 Max mac laptop. It does look like 50 -> 128 is a negligible performance impact in this pathological code sample at least. |
That FCW shouldn't be considered here as it's just a temporary band-aid to break less things when we stabilize the new solver. But I feel inclined to increasing our recursion limit to match with rustc in general, due to the following reason: Normally the greater recursion limits result in perf regressions against erroneous codes (and even in some correct ones❗ Some crates rely on refusing some candidates by hitting recursion limits. One of the most famous ones is But I think the worse case is the perf regressions on the correct codes that cannot be inferred correctly with the lower recursion limit. You can see an example for this in rust-lang/rust#162648, which reports I guess it's because of the reevaluations(or other general handlings) of overflowed goals which could be evaluated with non-ambiguous answer and thus avoidable in the bigger recursion limits and I think this might be pretty common in codes which require bigger recursion limits. |
Previously we had a recursion limit of 50 in the next_solver logic, which didn't match rustc. This prevents us generating SCIP files for some crates, and presumably would also stop r-a accepting code that rustc accepted.
For example, the
element-hq/matrix-authentication-serviceGitHub project at commit 8a6751398d7e9ea5cf28d48992bae99541431cd6 previously crashed during SCIP file creation.AI disclosure: Code was partly written by Opus 5, but comments, commit message and review by me.