Skip to content

Commit

Permalink
Lower the default local parallelism, and align the number of swimlane…
Browse files Browse the repository at this point in the history
…s to it. (#10499)

### Problem

It's pretty easy to overwhelm a machine with `2*multiprocessing.cpu_count()` processes running (especially since it frequently reports the number of virtual cores rather than physical cores), so this isn't a great default for local parallelism. Additionally, the number of swimlanes rendered in the dynamic UI is out of alignment with our configured parallelism.

### Solution

Lower the default parallelism to `multiprocessing.cpu_count()`, and align the swimlane count.

[ci skip-build-wheels]
  • Loading branch information
stuhood committed Jul 29, 2020
1 parent a11f5f6 commit 58ede94
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/python/pants/option/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def from_bootstrap_options(cls, bootstrap_options):
remote_store_chunk_upload_timeout_seconds=60,
remote_store_rpc_retries=2,
remote_store_connection_limit=5,
process_execution_local_parallelism=multiprocessing.cpu_count() * 2,
process_execution_local_parallelism=multiprocessing.cpu_count(),
process_execution_remote_parallelism=128,
process_execution_cleanup_local_dirs=True,
process_execution_speculation_delay=1,
Expand Down
1 change: 0 additions & 1 deletion src/rust/engine/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/rust/engine/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct Core {
pub vfs: PosixFS,
pub watcher: Arc<InvalidationWatcher>,
pub build_root: PathBuf,
pub local_parallelism: usize,
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -284,6 +285,7 @@ impl Core {
.map_err(|e| format!("Could not initialize VFS: {:?}", e))?,
build_root,
watcher,
local_parallelism: exec_strategy_opts.local_parallelism,
})
}

Expand Down
5 changes: 4 additions & 1 deletion src/rust/engine/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ impl Session {
) -> Session {
let workunit_store = WorkunitStore::new(should_render_ui);
let display = if should_render_ui {
Some(Mutex::new(ConsoleUI::new(workunit_store.clone())))
Some(Mutex::new(ConsoleUI::new(
workunit_store.clone(),
scheduler.core.local_parallelism,
)))
} else {
None
};
Expand Down
1 change: 0 additions & 1 deletion src/rust/engine/ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ uuid = { version = "0.7", features = ["v4"] }
logging = { path = "../logging" }
task_executor = { path = "../task_executor" }
workunit_store = { path = "../workunit_store" }
num_cpus = "1"
6 changes: 4 additions & 2 deletions src/rust/engine/ui/src/console_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ use workunit_store::WorkunitStore;

pub struct ConsoleUI {
workunit_store: WorkunitStore,
local_parallelism: usize,
// While the UI is running, there will be an Instance present.
instance: Option<Instance>,
}

impl ConsoleUI {
pub fn new(workunit_store: WorkunitStore) -> ConsoleUI {
pub fn new(workunit_store: WorkunitStore, local_parallelism: usize) -> ConsoleUI {
ConsoleUI {
workunit_store,
local_parallelism,
instance: None,
}
}
Expand Down Expand Up @@ -180,7 +182,7 @@ impl ConsoleUI {
}

// Setup bars, and then spawning rendering of the bars into a background task.
let (multi_progress, bars) = Self::setup_bars(num_cpus::get());
let (multi_progress, bars) = Self::setup_bars(self.local_parallelism);
let multi_progress_task = {
executor
.spawn_blocking(move || multi_progress.join())
Expand Down

0 comments on commit 58ede94

Please sign in to comment.