Skip to content
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

Cpu perf #2596

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Different approach, only listen on stdin when LOG_LEVEL=debug (which
is where dropping to a debugger is important).
  • Loading branch information
Narsil committed Oct 1, 2024
commit 41e674eea92ed169af5f6a106e57c73367692cae
24 changes: 11 additions & 13 deletions launcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,19 +915,19 @@ fn shard_manager(
}
});
// We read stdin in another thread as it seems that lines() can block in some cases
thread::spawn(move || {
let mut stdin = io::stdin(); // We get `Stdin` here.
loop {
let mut buffer = vec![0; 4096];
if let Ok(n) = stdin.read(&mut buffer) {
if n > 0 {
let _ = pstdin.write_all(&buffer[..n]);
} else {
break;
if LevelFilter::current() >= tracing::Level::DEBUG {
thread::spawn(move || {
let mut stdin = io::stdin(); // We get `Stdin` here.
loop {
let mut buffer = vec![0; 4096];
if let Ok(n) = stdin.read(&mut buffer) {
if n > 0 {
let _ = pstdin.write_all(&buffer[..n]);
}
}
}
}
});
});
}

let mut ready = false;
let start_time = Instant::now();
Expand Down Expand Up @@ -1065,8 +1065,6 @@ fn log_lines<R: Sized + Read>(mut bufread: BufReader<R>) {
}
}
}
} else {
break;
}
}
}
Expand Down
Loading