fix: reduce TUI idle CPU and improve server error banners
- Replace non-blocking try_recv() event loop with blocking recv() to eliminate idle spin; the sender tick timeout still drives minimum wakeup rate so the UI stays responsive - Lower default tick rate from 50 ms to 100 ms (10 ticks/sec vs 20); add MANAGARR_TICK_RATE_MS env var for runtime tuning - Move terminal draws to event boundaries (key + tick) instead of every loop pass, reducing unnecessary redraws - In network error handling, prefer concise JSON fields (message / errorMessage / error) over the raw HTTP body, so Radarr ASP.NET stack traces don't flood the TUI banner; full body still logged - Add unit tests for tick-rate parsing and Radarr-style JSON error body Observed: ~0.6% total CPU at idle vs measurably higher with prod defaults
This commit is contained in:
1 parent
6e7707f6df
commit
6c41e0704e
4 files changed
+114
-10
No files matched your search
+12
-4
@@ -276,22 +276,30 @@ async fn start_ui(
|
||||
|
||||
let input_events = Events::new();
|
||||
|
||||
loop {
|
||||
{
|
||||
let mut app = app.lock().await;
|
||||
|
||||
terminal.draw(|f| ui(f, &mut app))?;
|
||||
}
|
||||
|
||||
loop {
|
||||
match input_events.next()? {
|
||||
Some(InputEvent::KeyEvent(key)) => {
|
||||
let mut app = app.lock().await;
|
||||
|
||||
if key == Key::Char('q') && !app.ignore_special_keys_for_textbox_input {
|
||||
break;
|
||||
}
|
||||
|
||||
handlers::handle_events(key, &mut app);
|
||||
terminal.draw(|f| ui(f, &mut app))?;
|
||||
}
|
||||
|
||||
Some(InputEvent::Tick) => app.on_tick().await,
|
||||
_ => {}
|
||||
Some(InputEvent::Tick) => {
|
||||
let mut app = app.lock().await;
|
||||
app.on_tick().await;
|
||||
terminal.draw(|f| ui(f, &mut app))?;
|
||||
}
|
||||
None => break,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user