Skip to content
Draft
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
20 changes: 15 additions & 5 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ fn run_server_process(startup_timeout: Option<Duration>) -> Result<ServerStartup
trace!("run_server_process");
let tempdir = tempfile::Builder::new().prefix("sccache").tempdir()?;
let socket_path = tempdir.path().join("sock");
let runtime = Runtime::new()?;
let runtime = tokio::runtime::Builder::new_current_thread()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we allow running the server on more than one core? Only one server process should be used for all client connections.

P.S. Maybe the server concurrency should be limited to 4 or 8 threads and not executed on the all cores. And we should be ready for less than 4-core systems too (just use min of constant and hardware concurrency)

.enable_all()
.build()?;
let exe_path = env::current_exe()?;
let workdir = exe_path.parent().expect("executable path has no parent?!");

Expand Down Expand Up @@ -190,7 +192,9 @@ fn run_server_process(startup_timeout: Option<Duration>) -> Result<ServerStartup
trace!("run_server_process");

// Create a mini event loop and register our named pipe server
let runtime = Runtime::new()?;
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?;
let pipe_name = &format!(r"\\.\pipe\{}", Uuid::new_v4().as_simple());

// Spawn a server which should come back and connect to us
Expand Down Expand Up @@ -627,7 +631,9 @@ pub fn run_command(cmd: Command) -> Result<i32> {
// If there is no server, spawning a new server would start with zero stats
// anyways, so we can just return (mostly) empty stats directly.
Err(_) => {
let runtime = Runtime::new()?;
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?;
let storage = storage_from_config(config, runtime.handle()).ok();
runtime.block_on(ServerInfo::new(ServerStats::default(), storage.as_deref()))?
}
Expand Down Expand Up @@ -763,7 +769,9 @@ pub fn run_command(cmd: Command) -> Result<i32> {
use crate::compiler;

trace!("Command::PackageToolchain({})", executable.display());
let runtime = Runtime::new()?;
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?;
let jobserver = Client::new();
let creator = ProcessCommandCreator::new(&jobserver);
let args: Vec<_> = env::args_os().collect();
Expand Down Expand Up @@ -807,7 +815,9 @@ pub fn run_command(cmd: Command) -> Result<i32> {

let jobserver = Client::new();
let conn = connect_or_start_server(&get_addr(), startup_timeout)?;
let mut runtime = Runtime::new()?;
let mut runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?;
let res = do_compile(
ProcessCommandCreator::new(&jobserver),
&mut runtime,
Expand Down