- 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>
47 lines
2.2 KiB
Rust
47 lines
2.2 KiB
Rust
//! Game detection on Windows (admin.spec.md, "Game detection"): a program started from a launcher's
|
|
//! game folder turns game mode on with the folder's name, and off once it ends. Runs only with
|
|
//! `JARVIS_TEST_GAME_EXE=<a windowed program under ...\steamapps\common\<Game>\>`; elsewhere it skips.
|
|
//! For a game installed elsewhere (Battle.net) also set `JARVIS_TEST_GAME_LAUNCHER=Battle.net` and
|
|
//! `JARVIS_TEST_GAME_NAME=<its uninstall entry's name>`.
|
|
|
|
use std::time::{Duration, Instant};
|
|
|
|
use jarvis_app::game::GameWatch;
|
|
use jarvis_app::settings::GameSettings;
|
|
|
|
fn wait_for(w: &GameWatch, want: impl Fn(&serde_json::Value) -> bool, secs: u64) -> serde_json::Value {
|
|
let until = Instant::now() + Duration::from_secs(secs);
|
|
loop {
|
|
let v = w.view();
|
|
if want(&v) || Instant::now() > until {
|
|
return v;
|
|
}
|
|
std::thread::sleep(Duration::from_millis(200));
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn a_launcher_game_turns_game_mode_on_until_it_ends() {
|
|
let Ok(exe) = std::env::var("JARVIS_TEST_GAME_EXE") else {
|
|
eprintln!("skipped: set JARVIS_TEST_GAME_EXE");
|
|
return;
|
|
};
|
|
let w = GameWatch::start(GameSettings { detect: true, games: vec![], not_games: vec![], other_room_gb: 1.0, reserve_gb: 8.0, revert_seconds: 30, pause_in_game: false });
|
|
assert_eq!(w.view(), serde_json::Value::Null, "no game before it starts");
|
|
let mut game = std::process::Command::new(&exe).spawn().expect("the game starts");
|
|
let t0 = Instant::now();
|
|
let on = wait_for(&w, |v| !v.is_null(), 15);
|
|
eprintln!("on after {:?}: {on}", t0.elapsed());
|
|
let folder = std::path::Path::new(&exe).parent().unwrap().file_name().unwrap().to_string_lossy().into_owned();
|
|
let name = std::env::var("JARVIS_TEST_GAME_NAME").unwrap_or(folder);
|
|
let launcher = std::env::var("JARVIS_TEST_GAME_LAUNCHER").unwrap_or("Steam".into());
|
|
assert_eq!(on, serde_json::json!({"name": name, "reason": {"kind": "launcher", "launcher": launcher}}));
|
|
game.kill().unwrap();
|
|
let _ = game.wait();
|
|
let t1 = Instant::now();
|
|
let off = wait_for(&w, |v| v.is_null(), 10);
|
|
eprintln!("off after {:?}: {off}", t1.elapsed());
|
|
assert_eq!(off, serde_json::Value::Null, "game mode ends with the game");
|
|
w.stop();
|
|
}
|