Skip to content

Commit

Permalink
SYMPAL Fix Windows power usage
Browse files Browse the repository at this point in the history
Reverted the sleep back to 1ms instead of 1ns

I have no clue why but on Linux a 1ns loop will use 0% of a core while
on Windows it will use something like 90%

1ms drops Windows down to like 1% ish of a core so that's okay I guess?

The only thing done in the loop is relaxed loading an atomic so it's
clinically insane that Windows takes a million times as many cycles
  • Loading branch information
Beinsezii committed Aug 10, 2024
1 parent f2b83be commit 3acca92
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/library/player/sympal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ macro_rules! wait_on {
} else if combo_breaker.elapsed() > Duration::from_secs(5) {
break Err(concat!("Sympal timed out while waiting on ", $id, "!"));
} else {
thread::sleep(Duration::from_nanos(1))
thread::sleep(Duration::from_millis(1))
}
}
}};
Expand Down Expand Up @@ -323,7 +323,8 @@ impl Backend {
// not using wait_on! because its only purpose is
// to keep the stream object in scope until its done
while !join_thread.load(Ordering::Relaxed) {
thread::sleep(Duration::from_nanos(1))
// Millis instead of nanos because Windows will cook on the loop somehow
thread::sleep(Duration::from_millis(1))
}
streaming.store(false, Ordering::Relaxed);
}
Expand Down

0 comments on commit 3acca92

Please sign in to comment.