Uh oh!
There was an error while loading. Please reload this page.
rustdoc-search: depth limit T<U> -> U unboxing - #122247
Conversation
Profiler output: https://notriddle.com/rustdoc-html-demo-9/search-unbox-limit/ This is a performance enhancement aimed at a problem I found while using type-driven search on the Rust compiler. It is caused by [`Interner`], a trait with 41 associated types, many of which recurse back to `Self` again. This caused search.js to struggle. It eventually terminates, after about 10 minutes of turning my PC into a space header, but it's doing `41!` unifications and that's too slow. [`Interner`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/trait.Interner.html
rustbot
commented
Mar 9, 2024
rustbot
commented
Mar 9, 2024
Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @jsha |
GuillaumeGomez
commented
Mar 10, 2024
This is a great improvement, thanks! Could you add a |
notriddle
commented
Mar 11, 2024
Sure, the second commit now adds that.
I can't find any way to make compiletest do that, or precedent in other parts of the compiler to use it that way. Am I missing something? |
GuillaumeGomez
commented
Mar 11, 2024
I don't think we have a way to do this currently. I had in mind to add a timer for each search JS test we run and once we reach the limit, to kill the test execution. If you want I can take a look in a follow-up PR? If so r=me |
I don't think using setTimeout in Node will work, because the search will block the event loop and prevent the timer from actually firing. Doing it in a follow-up PR sounds like a good idea. This discussion should involve the compiletest maintainers. |
GuillaumeGomez
commented
Mar 11, 2024
I had something else in mind in fact with |
notriddle
commented
Mar 11, 2024
That still sounds like you're thinking of implementing the timeout in Node. Since search.js doesn't explicitly yield to the event loop (and, even if it did, we wouldn't want to rely on it for this kind of testing), the timer's callback won't be able to dispatch until the search is done. |
GuillaumeGomez
commented
Mar 11, 2024
You're right, we might need to use threads or subprocesses for that. But yes, I think it'd be better to have it done with node directly. |
GuillaumeGomez
commented
Mar 14, 2024
I'll add the test timeout in a follow-up. Thanks for this fix! @bors r+ rollup |
bors
commented
Mar 14, 2024
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#119029 (Avoid closing invalid handles) - rust-lang#122238 (Document some builtin impls in the next solver) - rust-lang#122247 (rustdoc-search: depth limit `T<U>` -> `U` unboxing) - rust-lang#122287 (add test ensuring simd codegen checks don't run when a static assertion failed) - rust-lang#122368 (chore: remove repetitive words) - rust-lang#122397 (Various cleanups around the const eval query providers) - rust-lang#122406 (Fix WF for `AsyncFnKindHelper` in new trait solver) - rust-lang#122477 (Change some attribute to only_local) - rust-lang#122482 (Ungate the `UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES` lint) - rust-lang#122490 (Update build instructions for OpenHarmony) Failed merges: - rust-lang#122471 (preserve span when evaluating mir::ConstOperand) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#122247 - notriddle:notriddle/search-unbox-limit, r=GuillaumeGomez rustdoc-search: depth limit `T<U>` -> `U` unboxing Profiler output: https://notriddle.com/rustdoc-html-demo-9/search-unbox-limit/ (the only significant change is that one of the `rust` tests went from 378416ms to 16ms). This is a performance enhancement aimed at a problem I found while using type-driven search on the Rust compiler. It is caused by [`Interner`], a trait with 41 associated types, many of which recurse back to `Self` again. This caused search.js to struggle. It eventually terminates, after about 10 minutes of turning my PC into a space header, but it's doing `41!` unifications and that's too slow. [`Interner`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/trait.Interner.html
Profiler output:
https://notriddle.com/rustdoc-html-demo-9/search-unbox-limit/ (the only significant change is that one of the
rusttests went from 378416ms to 16ms).This is a performance enhancement aimed at a problem I found while using type-driven search on the Rust compiler. It is caused by
Interner, a trait with 41 associated types, many of which recurse back toSelfagain.This caused search.js to struggle. It eventually terminates, after about 10 minutes of turning my PC into a space header, but it's doing
41!unifications and that's too slow.