fix(m0): judge game frames by what the screen showed and drop spoilt windows

- Frame rate, 1 % low and hitches come from msBetweenDisplayChange of the
  frames that reached the screen; frames never shown are counted apart and
  the presented rate is kept as presented_fps. A game presenting 60 fps
  while the screen changes every 167 ms now shows as the stutter it is.
- A window whose capture failed, a busy window where the LLM finished no
  answer, and every busy window when the STT load failed are not counted.
- A yielding window counts only when every Jarvis process got both its
  CPU and its GPU priority lowered.
- The "game hardly drawing" floor applies only with Jarvis off or idle, so
  a game Jarvis slows that far still counts as harm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-11 09:12:15 +09:00
parent dff18c5c7e
commit cec52165b2
4 changed files with 116 additions and 39 deletions

View File

@@ -49,7 +49,7 @@ LLM 단계는 8080 포트를 씁니다. 다른 프로그램이 이 포트를 쓰
- 게임 감지는 실행 중인 프로그램 이름과 창 모양만 봅니다. 게임 화면은 저장하지 않습니다. 설치된 게임은 이름과 안티치트 유무만 기록합니다.
- 음성 테스트는 키트에 들어 있는 합성 음성만 씁니다. 마이크는 쓰지 않습니다.
- 영상 끊김 단계(`video_drops`)는 유튜브에 공개된 Blender 영상을 새 임시 브라우저 프로필로 엽니다. 로그인하지 않고, 평소 쓰시는 프로필은 건드리지 않으며, 끝나면 그 임시 프로필을 지웁니다. 저장하는 것은 영상의 프레임 수, 끊긴 프레임 수, 화질, 광고가 나왔는지뿐입니다.
- 게임 프레임 단계(`game_frames`)는 PresentMon(인텔의 공개 도구)으로 게임이 프레임을 내보낸 시각만 기록합니다. 게임 화면은 보지 않고, 게임 이름이 든 원본 기록은 읽자마자 지웁니다. 저장하는 것은 fps, 1% low, 긴 프레임 수 같은 숫자뿐입니다.
- 게임 프레임 단계(`game_frames`)는 PresentMon(인텔의 공개 도구)으로 게임이 프레임을 내보낸 시각과 그 프레임이 화면에 나간 시각만 기록합니다. 게임 화면은 보지 않고, 게임 이름이 든 원본 기록은 읽자마자 지웁니다. 저장하는 것은 fps, 1% low, 긴 프레임 수 같은 숫자뿐입니다.
- PC 제어 도구 단계는 다른 프로그램의 창 제목과 화면 글자를 저장하지 않습니다. 개수, 걸린 시간, 오류 코드, 계산기 결과 숫자만 저장합니다. 이미 켜 둔 계산기가 있으면 건드리지 않고 그 확인을 건너뛰며, 브라우저는 평소 쓰시는 프로필이 아닌 새 임시 프로필로 엽니다.
## 옵션 (PowerShell에서 직접 실행할 때)
@@ -78,6 +78,6 @@ LLM 단계는 8080 포트를 씁니다. 다른 프로그램이 이 포트를 쓰
`run_m0_video.bat`을 더블클릭하면 Jarvis 옆에서 보는 영상이 끊기는지 잽니다(`video_drops`). 크롬(없으면 엣지)이 새 임시 프로필로 떠서 유튜브의 Blender 영상(Big Buck Bunny, 1080p 60fps, 소리 끔)을 틉니다. 광고가 나오면 건너뛸 수 있을 때 건너뛰고 끝날 때까지 기다립니다. 영상을 틀어 둔 채로 (1) Jarvis를 끈 상태 1분, (2) LLM(평소 배치, STT 자리와 여유 1GB)과 STT를 켜 두고 쉬는 상태 1분, (3) LLM이 답하고 STT가 10명 동시 전사를 쉬지 않고 하는 상태를 GPU 95% 제한 없이 두 번, 제한을 켜고 두 번, (4) 다시 Jarvis를 끈 상태 1분을 잽니다. 각각 끊긴 프레임 수(유튜브 "전문가용 통계"의 Dropped Frames와 같은 값)와, 화면에 프레임이 50ms·100ms 넘게 안 바뀐 횟수를 셉니다. 10~15분 걸립니다. 그동안 브라우저 창을 가리거나 최소화하지 말고 PC에 손대지 않으시면 됩니다. 광고, 일시정지, 버퍼링, 건너뛰기가 끼었거나 화질이 1080p 60fps가 아니었던 구간, 제한을 켰는데 Jarvis를 실제로 멈추지 못한 구간은 기록만 하고 비교에서는 뺍니다. 영상이 멈추거나 유튜브 오류가 뜨거나 페이지가 새로고침되면 키트가 알아서 다시 틀고(재생을 누르고, 안 되면 페이지를 다시 엽니다) 그 구간을 최대 3번까지 다시 잽니다. 직접 새로고침하지 않으셔도 됩니다. 화질이나 프레임 수가 떨어진 구간은 GPU 탓일 수 있어서 다시 재지 않습니다.
`run_m0_game_frames.bat`을 더블클릭하면 Jarvis가 게임 화면을 끊기게 하는지 잽니다(`game_frames`). 게임 프레임은 Windows 이벤트 기록으로 재므로 처음에 관리자 권한을 묻는 창이 한 번 뜹니다. 게임을 켜기 전에 "예"를 눌러 주세요. 그다음 게임을 켜고 플레이 화면까지 들어간 뒤 Enter를 누르고 15초 안에 게임으로 돌아가면 됩니다. 끝날 때까지 캐릭터를 한자리에 세워 두고 마우스·키보드에 손대지 마세요. 창마다 1분씩 (1) 게임만, (2) Jarvis(게임 중 배치)를 켜 두고 쉴 때, (3) LLM이 답하고 음성 인식이 최종 전사를 하는 동안을 그냥 두 번, Jarvis의 CPU·GPU 우선순위를 낮춰 게임에 양보하게 하고 두 번, (4) 다시 게임만 잽니다. 10~15분 걸리고 끝나면 알림음이 울립니다. 게임이 앞에 없었던 구간, 게임이 프레임을 거의 내지 않은 구간, 우선순위가 실제로 낮아지지 않은 양보 구간은 기록만 하고 비교에서 뺍니다. 프레임 제한(수직 동기화나 fps 제한)은 평소 쓰시는 대로 두셔도 됩니다.
`run_m0_game_frames.bat`을 더블클릭하면 Jarvis가 게임 화면을 끊기게 하는지 잽니다(`game_frames`). 게임 프레임은 Windows 이벤트 기록으로 재므로 처음에 관리자 권한을 묻는 창이 한 번 뜹니다. 게임을 켜기 전에 "예"를 눌러 주세요. 그다음 게임을 켜고 플레이 화면까지 들어간 뒤 Enter를 누르고 15초 안에 게임으로 돌아가면 됩니다. 끝날 때까지 캐릭터를 한자리에 세워 두고 마우스·키보드에 손대지 마세요. 창마다 1분씩 (1) 게임만, (2) Jarvis(게임 중 배치)를 켜 두고 쉴 때, (3) LLM이 답하고 음성 인식이 최종 전사를 하는 동안을 그냥 두 번, Jarvis의 CPU·GPU 우선순위를 낮춰 게임에 양보하게 하고 두 번, (4) 다시 게임만 잽니다. 10~15분 걸리고 끝나면 알림음이 울립니다. fps와 긴 프레임은 화면이 실제로 바뀐 간격으로 셉니다. 게임이 앞에 없었던 구간, 프레임 기록이 실패한 구간, Jarvis를 끄거나 쉬게 둔 동안 게임이 프레임을 거의 내지 않은 구간, LLM이나 음성 인식 부하가 제대로 돌지 않은 바쁨 구간, Jarvis 프로세스 하나라도 우선순위가 낮아지지 않은 양보 구간은 기록만 하고 비교에서 뺍니다. 프레임 제한(수직 동기화나 fps 제한)은 평소 쓰시는 대로 두셔도 됩니다.
다 끝나고 필요 없으면 작업 폴더(`\JarvisM0`)를 통째로 지우면 됩니다. Python, 모델, Strata(엔진과 설정 포함)는 모두 그 안에 설치하도록 지정해 두었습니다.

View File

@@ -41,7 +41,7 @@ PRESENTMON_SHA256 = "b2a706bc6ad475749e3b7e3409263aa1e6906d45bdcf993f6dbc0f66018
WINDOW_S = 60
SETTLE_S = 5 # Jarvis busy (or yielding) before a window starts
HITCH_MS = (50, 100) # a frame this long is a visible hitch
MIN_FRAMES = 300 # under this in a minute (5 fps) the game was not really drawing
MIN_FRAMES = 300 # under this in a minute (5 fps) with Jarvis off or idle, the game was not really drawing
ROUNDS = ("busy", "busy_yield", "busy_yield_2", "busy_2")
# The foreground window belongs to one of these when the user did not get back to the game.
NOT_A_GAME = {"windowsterminal.exe", "openconsole.exe", "conhost.exe", "cmd.exe", "powershell.exe",
@@ -183,12 +183,15 @@ class Yield:
def yield_problems(summary: dict) -> list[str]:
"""Why a yielding window did not yield: no process, nothing lowered, or a priority not put back."""
"""Why a yielding window did not yield: no process, a CPU or GPU priority left normal on any of
Jarvis's processes (yielding with some of them is not the yield being measured), or one not put back."""
out = []
if not summary.get("processes"):
n = summary.get("processes") or 0
if not n:
out.append("yield found no Jarvis process")
elif not summary.get("cpu_lowered") and not summary.get("gpu_lowered"):
out.append("yield lowered no priority")
for key, what in (("cpu_lowered", "CPU"), ("gpu_lowered", "GPU")):
if n and summary.get(key, 0) < n:
out.append(f"yield lowered the {what} priority of only {summary.get(key, 0)} of {n} processes")
if summary.get("not_restored"):
out.append(f"{summary['not_restored']} process(es) kept the lowered priority")
return out
@@ -252,26 +255,37 @@ def _num(value: str) -> float | None:
return None
def frame_stats(rows: list[dict], seconds: float) -> dict:
"""Frame rate, 1 % low (the 99th-percentile frame time as a rate) and hitches of the game's main
swap chain (the one with the most frames)."""
def frame_stats(rows: list[dict], seconds: float, min_frames: int = 0) -> dict:
"""What the screen showed of the game's main swap chain (the one with the most frames): the rate of
shown frames, the 1 % low (the 99th-percentile time between screen updates as a rate) and hitches,
all from the time each shown frame stayed before the next (msBetweenDisplayChange). A frame the
game presented but the screen never showed is counted in ``not_shown``; the rate the game
presented at is kept apart (``presented_fps``), since a game can present at 60 fps while the
screen changes far less often. ``min_frames`` (per minute) marks a window where the game was
hardly drawing; it is only given with Jarvis off or idle, so a game Jarvis slows down that much
still counts as the harm it is."""
chains: dict[str, list[dict]] = {}
for x in rows:
chains.setdefault(x.get("swapchainaddress", ""), []).append(x)
main = max(chains.values(), key=len) if chains else []
ms = [v for v in (_num(x.get("msbetweenpresents")) for x in main[1:]) if v is not None and v > 0]
out: dict[str, Any] = {"seconds": round(seconds, 1), "frames": len(ms)}
main = (max(chains.values(), key=len) if chains else [])[1:] # the first reaches back before the capture
presents = [v for v in (_num(x.get("msbetweenpresents")) for x in main) if v is not None and v > 0]
shown = [x for x in main if x.get("dropped") != "1"]
ms = [v for v in (_num(x.get("msbetweendisplaychange")) for x in shown) if v is not None and v > 0][1:]
out: dict[str, Any] = {"seconds": round(seconds, 1), "frames": len(ms), "presented": len(presents),
"not_shown": len(main) - len(shown)}
if presents:
out["presented_fps"] = round(len(presents) / (sum(presents) / 1000), 1)
if not ms:
return {**out, "valid": False, "invalid_because": ["the game drew no frames"]}
why = "the game drew no frames" if not presents else "PresentMon saw none of the frames reach the screen"
return {**out, "valid": False, "invalid_because": [why]}
srt = sorted(ms)
p99 = srt[min(len(srt) - 1, int(len(srt) * 0.99))]
out.update(fps=round(len(ms) / (sum(ms) / 1000), 1), low1_fps=round(1000 / p99, 1),
p99_ms=round(p99, 2), max_ms=round(srt[-1], 1),
hitches_over_ms={str(h): sum(v > h for v in ms) for h in HITCH_MS},
not_shown=sum(x.get("dropped") == "1" for x in main[1:]))
hitches_over_ms={str(h): sum(v > h for v in ms) for h in HITCH_MS})
reasons = []
if len(ms) < MIN_FRAMES * seconds / 60:
reasons.append(f"the game drew only {len(ms)} frames")
if len(ms) < min_frames * seconds / 60:
reasons.append(f"the screen showed only {len(ms)} of the game's frames")
out["valid"] = not reasons
if reasons:
out["invalid_because"] = reasons
@@ -361,6 +375,11 @@ def ask_for_a_game() -> bool:
return True
def _spoil(x: dict, why: str) -> None:
x["game"]["valid"] = False
x["game"]["invalid_because"] = x["game"].get("invalid_because", []) + [why]
def measure(r: StageResult, s: "llm.Strata", preset: dict, context: int, stt_python: str) -> None:
work = s.log.parent.parent
pm_log = s.log.with_name("presentmon.log")
@@ -393,14 +412,17 @@ def measure(r: StageResult, s: "llm.Strata", preset: dict, context: int, stt_pyt
x["vram_free_mib"] = used[1] - used[0]
with gpucap.UtilSampler() as util:
frames, err = capture(pm, game, WINDOW_S, work / "cache" / "frames.csv", pm_log)
g = frame_stats(frames, WINDOW_S)
g = frame_stats(frames, WINDOW_S, MIN_FRAMES if kind in ("off", "idle") else 0)
g["gpu_util"] = util.summary()
now = foreground_process()
if now is not None and now[0] != game:
g["valid"] = False
g["invalid_because"] = g.get("invalid_because", []) + ["the game was not in front at the end"]
if err:
# Frames from a capture that failed or was cut off do not cover the window.
r.error(f"frames {key}", err)
g["valid"] = False
g["invalid_because"] = g.get("invalid_because", []) + [f"the capture failed ({err})"]
x["game"] = g
rows.append(x)
if not g["valid"]:
@@ -450,20 +472,27 @@ def measure(r: StageResult, s: "llm.Strata", preset: dict, context: int, stt_pyt
x["llm"] = busy.summary()
for err in x["llm"]["errors"]:
r.error(f"frames {key} llm", err)
if not x["llm"]["decode_tok_s"].get("n"):
# Jarvis was not busy, so the window measured the game next to an idle Jarvis.
r.error(f"frames {key} llm", "no answer finished during the window")
_spoil(x, "the LLM finished no answer during the window")
if yielding:
x["yield"] = y.summary()
problems = yield_problems(x["yield"])
for why in problems:
r.error(f"frames {key} yield", why)
if problems:
x["game"]["valid"] = False
x["game"]["invalid_because"] = x["game"].get("invalid_because", []) + problems
for why in problems:
_spoil(x, why)
r.save()
busy_stt = stt.finish()
r["stt_busy"] = {k: busy_stt.get(k) for k in ("status", "single_s", "errors", "final_wait_s")
if k in busy_stt}
for err in llm.stt_gaps(busy_stt, llm._FINALS_ONLY):
r.error("frames stt", err)
# The STT's part of the load is not known to have run, in any busy window.
for x in rows:
if x["kind"].startswith("busy"):
_spoil(x, f"the STT load failed ({err})")
stt.close()
stt = None
s.stop()