Skip to content

Commit a7314a1

Browse files
committed
Fix CPU hogging in interactive mode
The log enabler should be checked after the sleep instead of a busy loop checking. Since the interactive mode always disables the token speed logger, 100% CPU was taken by this loop always. (This another busy loop problem which will be fixed in another PR.)
1 parent a63da3c commit a7314a1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mistralrs-core/src/engine/logger.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ impl IntervalLogger {
2727
let t_total_new_seqs = total_new_seqs.clone();
2828
let t_enable_logging = enable_logging.clone();
2929
thread::spawn(move || {
30-
// Wait
31-
while !t_enable_logging.load(Ordering::Relaxed) {}
32-
3330
// Start the actual logging
3431
loop {
3532
thread::sleep(interval);
33+
if !t_enable_logging.load(Ordering::Relaxed) {
34+
continue;
35+
}
3636

3737
let total_new_seqs = t_total_new_seqs.load(Ordering::Relaxed);
3838
let prefix_cache_hits = t_prefix_cache_hits.load(Ordering::Relaxed);

0 commit comments

Comments
 (0)