Parallel frontend compiler support (perf backend only)#2491
Conversation
from andrew.zhogin@gmail.com: 3ffe80f
as proposed by berykubik@gmail.com in the discussion of the preceding pr
|
Thanks for the PR! Let's revert the last commit; the CI failure shows why we need to have a custom environment variable, so that it will also work with a stable Rust compiler. |
544995b to
4f11ea4
Compare
|
I'm not sure I quite like a separate environment variable for that; don't we have a better mechanism? Also, maybe a collector run shouldn't silently revert to single-threaded scenario in an unsupported version, which it currently does, for my understanding? However, it seems like it's a common behavior in // ...
let profiles = if collector::version_supports_doc(&toolchain.id) {
vec![Profile::Check, Profile::Debug, Profile::Doc, Profile::Opt]
} else {
vec![Profile::Check, Profile::Debug, Profile::Opt]
};
let scenarios = if collector::version_supports_incremental(&toolchain.id) {
Scenario::all()
} else {
Scenario::all_non_incr()
};
let frontend_threads_counts = if collector::version_supports_parallel_frontend(&toolchain.id) {
FrontendThreads::default_opts()
} else {
vec![FrontendThreads(1)]
};
// ...So it might be i'm looking too hard into it... |
|
|
Kobzol
left a comment
There was a problem hiding this comment.
Thanks for separating the PR! Did a first review pass. Adding a new benchmark axis is always cumbersome, as it requires changing many places, and this one is also tricky, because it doesn't have a closed set of values, but is just a number. But in general it looks good, just
Please revert all the site changes, the integration with the frontend and also the job queuing system should be done in a follow-up PR. For now everything on production will just assume frontend count 1.
| benchmark.name, | ||
| profile, | ||
| scenario, | ||
| frontend_threads.par_n(), |
There was a problem hiding this comment.
Let's remove the par_n function, it contains a hardcoded string prefix that is then used in several places. That shouldn't belong in the database module.
| #[arg( | ||
| long = "frontend-threads", | ||
| value_delimiter = ',', | ||
| default_value = "1,4" |
There was a problem hiding this comment.
| default_value = "1,4" | |
| default_value = "1" |
The default should just be one for now, we don't need to test multiple values by default, it would just make local runs unnecessarily slower.
| }, | ||
| bench_rustc, | ||
| targets: vec![job.target().into()], | ||
| frontend_threads: FrontendThreads::default_opts(), |
There was a problem hiding this comment.
| frontend_threads: FrontendThreads::default_opts(), | |
| frontend_threads: FrontendThreads::default_value(), |
And also change the default to just [1].
| let frontend_threads_counts = if collector::version_supports_parallel_frontend(&toolchain.id) { | ||
| FrontendThreads::default_opts() | ||
| } else { | ||
| vec![FrontendThreads(1)] |
There was a problem hiding this comment.
Hmm, this is tricky, because for the old version that doesn't support the flag, we would either:
- Not pass the
RUSTC_THREAD_COUNTat all (which happens now). That works for the old compiler, but if we change the default thread count in the future, then setting--frontend-threads=1will actually use the default number of threads, which is misleading. - Still try to pass
-Zthreads=1. That will ensure that we are using the right number of threads, but it will break benchmarking on Rust <1.33.0.
I would suggest changing this to always pass the flag. It is better to break benchmarking on Rust <1.33.0, which likely won't be needed in the near future, than to use an unexpected thread count by mistake.
| if self.frontend_threads.0 != 1 { | ||
| cmd.env("RUSTC_THREAD_COUNT", self.frontend_threads.0.to_string()); | ||
| } |
There was a problem hiding this comment.
| if self.frontend_threads.0 != 1 { | |
| cmd.env("RUSTC_THREAD_COUNT", self.frontend_threads.0.to_string()); | |
| } | |
| cmd.env("RUSTC_THREAD_COUNT", self.frontend_threads.0.to_string()); |
| .raw() | ||
| .prepare( | ||
| "select id, crate, profile, scenario, backend, target, metric from pstat_series;", | ||
| "select id, crate, profile, scenario, backend, target, metric, frontend_threads from pstat_series;", |
There was a problem hiding this comment.
| "select id, crate, profile, scenario, backend, target, metric, frontend_threads from pstat_series;", | |
| "select id, crate, profile, scenario, backend, target, frontend_threads, metric from pstat_series;", |
And everywhere else.
| Metric, | ||
| FrontendThreads, |
There was a problem hiding this comment.
| Metric, | |
| FrontendThreads, | |
| FrontendThreads, | |
| Metric, |
| metric: Selector<crate::Metric>, | ||
| frontend_threads: Selector<FrontendThreads>, | ||
| target: Selector<Target>, |
There was a problem hiding this comment.
| metric: Selector<crate::Metric>, | |
| frontend_threads: Selector<FrontendThreads>, | |
| target: Selector<Target>, | |
| target: Selector<Target>, | |
| frontend_threads: Selector<FrontendThreads>, | |
| metric: Selector<crate::Metric>, |
| │ metric │ └──────────┘ | ||
| │ target | | ||
| │ frontend_threads | |
There was a problem hiding this comment.
| │ metric │ └──────────┘ | |
| │ target | | |
| │ frontend_threads | | |
| │ frontend_threads │ └──────────┘ | |
| │ target | | |
| │ metric | |
| * **metric** (`text`): the type of metric being collected. | ||
| * **frontend_threads** (`text`): Parallel frontend thread count ('-Zthreads=N'). |
There was a problem hiding this comment.
| * **metric** (`text`): the type of metric being collected. | |
| * **frontend_threads** (`text`): Parallel frontend thread count ('-Zthreads=N'). | |
| * **frontend_threads** (`text`): Parallel frontend thread count ('-Zthreads=N'). | |
| * **metric** (`text`): the type of metric being collected. |
Seems like we are missing the target here (pre-existing), could you please add it? Thanks!
|
Thanks for the fast yet sizable review! I'm sorry for calling out for you so early; i'm not sure this pr is quite review-ready. I'll try to resolve what you commented for now and then dive more into how this works! As until now all i did is brainless-ish renaming, lol |
|
To be fair, adding a new benchmark axis mostly involves a lot of brainless-ish renaming :) I think that the PR is mostly good to go, though it will require a couple of follow-up PRs to:
|
Supersedes #2421, but only backend (profiler/bencher/database). As said in parent pr, parallel frontend support is implemented as additional dimension with corresponding row added to the database