-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up rustdoc startup #102769
Clean up rustdoc startup #102769
Commits on Oct 18, 2022
-
rustc's startup has several layers, including: - `interface::run_compiler` passes a closure, `f`, to `run_in_thread_pool_with_globals`, which creates a thread pool, sets up session globals, and passes `f` to `create_compiler_and_run`. - `create_compiler_and_run` creates a `Session`, a `Compiler`, sets the source map, and calls `f`. rustdoc is a bit different. - `main_args` calls `main_options` via `run_in_thread_pool_with_globals`, which (again) creates a thread pool (hardcoded to a single thread!) and sets up session globals. - `main_options` has four different paths. - The second one calls `interface::run_compiler`, which redoes the `run_in_thread_pool_with_globals`! This is bad. - The fourth one calls `interface::create_compiler_and_run`, which is reasonable. - The first and third ones don't do anything of note involving the above functions, except for some symbol interning which requires session globals. In other words, rustdoc calls into `rustc_interface` at three different levels. It's a bit confused, and feels like code where functionality has been added by different people at different times without fully understanding how the globally accessible stuff is set up. This commit tidies things up. It removes the `run_in_thread_pool_with_globals` call in `main_args`, and adjust the four paths in `main_options` as follows. - `markdown::test` calls `test::test_main`, which provides its own parallelism and so doesn't need a thread pool. It had one small use of symbol interning, which required session globals, but the commit removes this. - `doctest::run` already calls `interface::run_compiler`, so it doesn't need further adjustment. - `markdown::render` is simple but needs session globals for interning (which can't easily be removed), so it's now wrapped in `create_session_globals_then`. - The fourth path now uses `interface::run_compiler`, which is equivalent to the old `run_in_thread_pool_with_globals` + `create_compiler_and_run` pairing.
Configuration menu - View commit details
-
Copy full SHA for 021d1fb - Browse repository at this point
Copy the full SHA 021d1fbView commit details -
Merge
main_options
intomain_args
.There is no longer any need for them to be separate.
Configuration menu - View commit details
-
Copy full SHA for 2a62c92 - Browse repository at this point
Copy the full SHA 2a62c92View commit details -
Inline and remove
scoped_thread
.It has a single call site, and removing it slightly improves the confusing tangle of nested closures present at startup.
Configuration menu - View commit details
-
Copy full SHA for 134e9d3 - Browse repository at this point
Copy the full SHA 134e9d3View commit details -
Configuration menu - View commit details
-
Copy full SHA for dcc194e - Browse repository at this point
Copy the full SHA dcc194eView commit details -
Inline and remove
create_compiler_and_run
.It has a single call site.
Configuration menu - View commit details
-
Copy full SHA for b6ae145 - Browse repository at this point
Copy the full SHA b6ae145View commit details -
Apply
Lrc
later tosess
andcodegen_backend
.This avoids the need for a degenerate `Lrc::get_mut` call.
Configuration menu - View commit details
-
Copy full SHA for ec409f9 - Browse repository at this point
Copy the full SHA ec409f9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 63db9e5 - Browse repository at this point
Copy the full SHA 63db9e5View commit details -
Use
interface::run_compiler
formarkdown::render
.It turns out `markdown::render` is more complex than it first appears, because it can invoke `doctest::make_test`, which requires session globals and a thread pool. So this commit changes it to use `interface::run_compiler`. Three of the four paths in `main_args` now use `interface::run_compiler`.
Configuration menu - View commit details
-
Copy full SHA for 38988e6 - Browse repository at this point
Copy the full SHA 38988e6View commit details -
By moving `RenderOptions` out of `Option`, because the two structs' uses are almost entirely separate. The only complication is that `unstable_features` is needed in both structs, but it's a tiny `Copy` type so its duplication seems fine.
Configuration menu - View commit details
-
Copy full SHA for ca2561a - Browse repository at this point
Copy the full SHA ca2561aView commit details