Unverified Commit 3ea82d00 authored by Nicolas Patry's avatar Nicolas Patry Committed by GitHub
Browse files

Cpu perf (#2596)



* break when there's nothing to read
Signed-off-by: default avatarWang, Yi A <yi.a.wang@intel.com>

* Different approach, only listen on stdin when `LOG_LEVEL=debug` (which
is where dropping to a debugger is important).

---------
Signed-off-by: default avatarWang, Yi A <yi.a.wang@intel.com>
Co-authored-by: default avatarWang, Yi A <yi.a.wang@intel.com>
parent ce28ee88
...@@ -944,17 +944,19 @@ fn shard_manager( ...@@ -944,17 +944,19 @@ fn shard_manager(
} }
}); });
// We read stdin in another thread as it seems that lines() can block in some cases // We read stdin in another thread as it seems that lines() can block in some cases
thread::spawn(move || { if LevelFilter::current() >= tracing::Level::DEBUG {
let mut stdin = io::stdin(); // We get `Stdin` here. thread::spawn(move || {
loop { let mut stdin = io::stdin(); // We get `Stdin` here.
let mut buffer = vec![0; 4096]; loop {
if let Ok(n) = stdin.read(&mut buffer) { let mut buffer = vec![0; 4096];
if n > 0 { if let Ok(n) = stdin.read(&mut buffer) {
let _ = pstdin.write_all(&buffer[..n]); if n > 0 {
let _ = pstdin.write_all(&buffer[..n]);
}
} }
} }
} });
}); }
let mut ready = false; let mut ready = false;
let start_time = Instant::now(); let start_time = Instant::now();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment