fix(app): log the card's real free memory, and short answers get their line too
Free memory is nvidia-smi's memory.free in the app and the voice worker, so the driver's reserved share no longer counts as free. A card reading still running when an answer ends finishes on its own and then logs, so an answer shorter than one reading is logged too, and the answer still never waits for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1578,8 +1578,9 @@ def test_each_answer_logs_the_least_graphics_memory_free_while_it_was_written(st
|
||||
import time as _time
|
||||
from voice_worker import server as worker_server
|
||||
monkeypatch.setattr(worker_server, "CARD_EVERY_S", 0.02)
|
||||
readings = iter([9000, 15000, 12000])
|
||||
last = [12000]
|
||||
# Free memory as nvidia-smi reports it (the driver's reserved share is not free).
|
||||
readings = iter([7000, 859, 3000])
|
||||
last = [3000]
|
||||
|
||||
def card():
|
||||
last[0] = next(readings, last[0])
|
||||
@@ -1602,7 +1603,7 @@ def test_each_answer_logs_the_least_graphics_memory_free_while_it_was_written(st
|
||||
reply = [x for x in lines if "answer r1" in x]
|
||||
task = [x for x in lines if "task t1" in x]
|
||||
assert len(reply) == 1 and len(task) == 1, lines
|
||||
assert f"least {16303 - 15000} MiB free of 16303 MiB" in reply[0], reply
|
||||
assert "least 859 MiB free of 16303 MiB" in reply[0], reply
|
||||
assert "private" not in "".join(lines) and "secret" not in "".join(lines)
|
||||
|
||||
|
||||
@@ -1616,3 +1617,29 @@ def test_without_a_card_reading_an_answer_logs_no_card_line(store, capfd):
|
||||
|
||||
asyncio.run(with_worker(body, store=store, brain=FakeBrain(), card=lambda: None))
|
||||
assert "MiB free" not in capfd.readouterr().err
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_an_answer_done_before_the_first_card_reading_is_logged_once_the_reading_ends(store, capfd):
|
||||
"""A short answer is not held for the card, and still gets its line once the reading ends."""
|
||||
import threading
|
||||
reading = threading.Event()
|
||||
|
||||
def card():
|
||||
reading.wait(5)
|
||||
return 2048, 16303
|
||||
|
||||
async def body(url):
|
||||
async with connect(url) as ws:
|
||||
await hello(ws)
|
||||
await send(ws, type="reply", id="r1", user="100", text="q", via="chat", speak=False)
|
||||
await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "reply_text")
|
||||
before = capfd.readouterr().err
|
||||
reading.set()
|
||||
await asyncio.sleep(0.3)
|
||||
return before
|
||||
|
||||
before = asyncio.run(with_worker(body, store=store, brain=FakeBrain(), card=card))
|
||||
after = capfd.readouterr().err
|
||||
assert "answer r1 card" not in before, "the answer did not wait for the card"
|
||||
assert "answer r1 card: least 2048 MiB free of 16303 MiB (1 readings" in after, after[-1500:]
|
||||
|
||||
Reference in New Issue
Block a user