Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ parallel = ["dep:nagoya"]
# nagoya's pool, for `parallel` only. `Runtime::builder().stack_size`, `Executor::{submit, pool}`
# and `block_on` are what this crate calls. Default features, because `std` is the point: see the
# `parallel` feature above.
# Moves to the crates.io release (`^0.1.14`) once nagoya publishes `Runtime::builder`.
nagoya = { git = "https://github.com/pathscale/nagoya", branch = "feat/stack-size", optional = true }
# `Runtime::builder` arrived in 0.1.14.
nagoya = { version = "^0.1.14", optional = true }
# The two crates that could not be merged. `rustc_macros` is the historical name and the source
# still says `rustc_macros::`, so it is aliased rather than renamed across ten thousand sites.
rustc_macros = { package = "frontend_macros", path = "frontend_macros", version = "0.2.0", optional = true }
rustc_macros = { package = "frontend_macros", path = "frontend_macros", version = "0.3.0", optional = true }
frontend_diag_template = { path = "frontend_diag_template", version = "0.1.1" }
# Not a module, deliberately. See `frontend_arena/Cargo.toml`.
frontend_arena = { path = "frontend_arena", version = "0.2.0" }
Expand Down Expand Up @@ -137,7 +137,7 @@ unicode-width = "0.2.2"
[dev-dependencies]
# The timing example sizes its own nagoya pool (`--pool N`) and hands it over with
# `sync::set_parallel_executor`, to measure scaling at pool sizes other than the default.
nagoya = { git = "https://github.com/pathscale/nagoya", branch = "feat/stack-size" }
nagoya = "^0.1.14"
# The pool's idle policy for `--tuning` (`Builder::tuning` takes fanout's `Tuning`, which nagoya
# does not re-export).
ps-st3 = { version = "^0.6", default-features = false, features = ["fanout"] }
Expand Down
17 changes: 13 additions & 4 deletions examples/parallel_timing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,17 @@ fn pass_of(text: &str) -> &'static str {
"other"
}

/// Hand `executor` to frontend as the pool its stages run on. Only a build with the `parallel`
/// feature has stages to run there; without it every session is serial and the pool this
/// program built still runs whole files side by side (`files`).
fn hand_over(executor: nagoya::Executor) {
#[cfg(feature = "parallel")]
frontend::rustc_data_structures::sync::set_parallel_executor(executor)
.unwrap_or_else(|_| panic!("an executor was already set"));
#[cfg(not(feature = "parallel"))]
drop(executor);
}

fn catcher(f: &mut dyn FnMut()) -> Result<(), frontend::unwind_janky::Payload> {
std::panic::catch_unwind(std::panic::AssertUnwindSafe(f))
}
Expand Down Expand Up @@ -581,8 +592,7 @@ fn main() {
let executor = runtime.executor().clone_handle();
// Kept for the life of the program: dropping a `Runtime` does not stop its workers.
std::mem::forget(runtime);
frontend::rustc_data_structures::sync::set_parallel_executor(executor)
.unwrap_or_else(|_| panic!("an executor was already set"));
hand_over(executor);
println!("pool: {workers} workers");
}
let mut args = raw.into_iter();
Expand Down Expand Up @@ -618,8 +628,7 @@ fn main() {
let pool = Arc::clone(runtime.pool());
let executor = runtime.executor().clone_handle();
std::mem::forget(runtime);
frontend::rustc_data_structures::sync::set_parallel_executor(executor)
.unwrap_or_else(|_| panic!("an executor was already set"));
hand_over(executor);
let run = || -> (Vec<Checked>, f64) {
let slots: Arc<Vec<std::sync::OnceLock<Checked>>> =
Arc::new((0..files.len()).map(|_| std::sync::OnceLock::new()).collect());
Expand Down
2 changes: 1 addition & 1 deletion frontend_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "frontend_macros"
version = "0.2.0"
version = "0.3.0"
edition = "2024"
license = "Apache-2.0 OR MIT"
description = "the derives and attribute macros the frontend crate is built from"
Expand Down
10 changes: 0 additions & 10 deletions src/frontend_facts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,16 +524,6 @@ fn extract_with(tcx: TyCtxt<'_>, bodies: bool) -> CrateFacts {
// The second stage takes them after every other body, each after its owner's signature is
// lowered (`lower_signature`), which is the state rustc checks them in.
//
// In rustc's order, in two stages. The first takes every body rustc's own body loop
// (`rustc_hir_analysis::check_crate`) type-checks. That loop skips an anon const of the type
// system (an array length, a const generic argument): such a const's type is fed while the
// signature or body around it is lowered, and rustc lowers every signature before it checks
// any body. This walk does not run that crate-wide lowering (it would stop a `no_core` file
// on its first missing lang item), so checking those consts in index order reached one before
// its type was fed: core, which has no other error to stop at first, ended in delayed bugs.
// The second stage takes them after every other body, each after its owner's signature is
// lowered (`lower_signature`), which is the state rustc checks them in.
//
// A body weighs its source at type checking's rate (`sync::cost::TYPECK`), which is what
// most of its fact costs, so a small file's bodies run serially, as width one runs them.
// The two stages above stay unweighted, cut by count: their items cost a path printed per
Expand Down