feat(app): performance stages move the LLM between the normal and the game placement

- while the services run, game mode decides the stage (perf.rs): a game means the game stage at
  once (or pause with game.pauseInGame); its end brings the normal stage back after
  game.revertSeconds (default 30)
- a change tells the voice worker the LLM switches (llm switching, with a notice), waits until
  the brain has written the answers in progress (llm_idle, at most 2 minutes), restarts the LLM in
  the stage and tells the worker it is ready or paused
- the game stage runs at 16K context, one request at a time, half the engine's CPU threads and
  the game placement (reserve game.reserveGb, default 8, else 2 GiB, else 0 GiB, else pause),
  measured once at that context; every placement of a run counts other programs' memory as it
  was when the services started
- the voice worker gates every LLM use: on switching new work waits (at most 180 s), the first
  spoken request that waits hears the notice once under its own id, on ready all go on, on
  paused nothing is answered
- dashboard: "성능 단계: 게임 중 · 게임에 X GB" / 일시정지; game mode screen: game VRAM, revert
  wait, pause in game

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-14 10:23:21 +09:00
parent b6bd1be6fb
commit 7e096b449e
18 changed files with 746 additions and 68 deletions

View File

@@ -109,12 +109,22 @@ pub struct GameSettings {
pub not_games: Vec<String>,
/// Graphics memory the normal placement leaves for programs opened later (GB, default 1).
pub other_room_gb: f64,
/// Graphics memory a game gets in the game stage (GB, default 8).
pub reserve_gb: f64,
/// How long after a game ends the normal stage comes back (seconds, default 30).
pub revert_seconds: u32,
/// Stop the LLM while a game runs (default off).
pub pause_in_game: bool,
}
impl GameSettings {
pub fn other_room_mib(&self) -> i64 {
(self.other_room_gb * 1024.0).round() as i64
}
pub fn reserve_mib(&self) -> i64 {
(self.reserve_gb * 1024.0).round() as i64
}
}
/// Background collection (admin.spec.md, "Background collection"); no targets by default.
@@ -210,7 +220,7 @@ impl Default for Settings {
features: FeatureSettings { weather: true, web_search: true, meals: true, collect: true, browser: true, browser_share: false },
mcp_servers: vec![],
collect: CollectSettings { keep_days: 30, targets: vec![] },
game: GameSettings { detect: true, games: vec![], not_games: vec![], other_room_gb: 1.0 },
game: GameSettings { detect: true, games: vec![], not_games: vec![], other_room_gb: 1.0, reserve_gb: 8.0, revert_seconds: 30, pause_in_game: false },
}
}
}
@@ -571,15 +581,21 @@ fn parse_game(raw: &Map<String, Value>, d: &GameSettings) -> Result<GameSettings
}
Ok(v)
};
let other_room_gb = match g.and_then(|m| m.get("otherRoomGb")) {
None => d.other_room_gb,
Some(v) => match v.as_f64() {
Some(n) if (0.0..=8.0).contains(&n) => n,
_ => return err("game.otherRoomGb must be a number 0-8 (GB)"),
},
let gb = |key: &str, default: f64, max: f64| -> Result<f64, SettingsError> {
match g.and_then(|m| m.get(key)) {
None => Ok(default),
Some(v) => match v.as_f64() {
Some(n) if (0.0..=max).contains(&n) => Ok(n),
_ => err(format!("game.{key} must be a number 0-{max} (GB)")),
},
}
};
let other_room_gb = gb("otherRoomGb", d.other_room_gb, 8.0)?;
let reserve_gb = gb("reserveGb", d.reserve_gb, 32.0)?;
let revert_seconds = get_uint(g, "revertSeconds", "game", d.revert_seconds, 0, 600)?;
Ok(GameSettings { detect: get_bool(g, "detect", "game", d.detect)?, games: list("games", &d.games)?,
not_games: list("notGames", &d.not_games)?, other_room_gb })
not_games: list("notGames", &d.not_games)?, other_room_gb, reserve_gb, revert_seconds,
pause_in_game: get_bool(g, "pauseInGame", "game", d.pause_in_game)? })
}
fn parse_collect(raw: &Map<String, Value>, d: &CollectSettings) -> Result<CollectSettings, SettingsError> {
@@ -851,11 +867,13 @@ mod tests {
#[test]
fn game_detection_settings_are_read_and_checked() {
assert_eq!(parse_settings(&json!({})).unwrap().game, GameSettings { detect: true, games: vec![], not_games: vec![], other_room_gb: 1.0 });
let s = parse_settings(&json!({"game": {"detect": false, "games": [" MyGame.exe ", ""], "notGames": ["obs64"], "otherRoomGb": 2.5}})).unwrap();
assert_eq!(s.game, GameSettings { detect: false, games: vec!["MyGame.exe".into()], not_games: vec!["obs64".into()], other_room_gb: 2.5 });
assert_eq!(parse_settings(&json!({})).unwrap().game, GameSettings { detect: true, games: vec![], not_games: vec![], other_room_gb: 1.0, reserve_gb: 8.0, revert_seconds: 30, pause_in_game: false });
let s = parse_settings(&json!({"game": {"detect": false, "games": [" MyGame.exe ", ""], "notGames": ["obs64"], "otherRoomGb": 2.5, "reserveGb": 6, "revertSeconds": 60, "pauseInGame": true}})).unwrap();
assert_eq!(s.game, GameSettings { detect: false, games: vec!["MyGame.exe".into()], not_games: vec!["obs64".into()], other_room_gb: 2.5,
reserve_gb: 6.0, revert_seconds: 60, pause_in_game: true });
assert_eq!(s.game.reserve_mib(), 6144);
assert_eq!(s.game.other_room_mib(), 2560);
for bad in [json!({"game": {"games": ["C:\\x\\a.exe"]}}), json!({"game": {"notGames": "a"}}), json!({"game": {"detect": 1}}), json!({"game": {"otherRoomGb": 9}})] {
for bad in [json!({"game": {"games": ["C:\\x\\a.exe"]}}), json!({"game": {"notGames": "a"}}), json!({"game": {"detect": 1}}), json!({"game": {"otherRoomGb": 9}}), json!({"game": {"revertSeconds": 601}}), json!({"game": {"reserveGb": -1}})] {
assert!(parse_settings(&bad).unwrap_err().0.contains("game."), "{bad}");
}
}