V46: FILL 48->96 (cushion ~512ms) chong stall ~500ms (u2 deficit 723ms) + instrument 3 lop (wl_gap/main_in_gap/pump_hb)

This commit is contained in:
2026-08-29 09:01:35 +07:00
parent 2a3e5bf08f
commit 2b334c0812
3 changed files with 36 additions and 3 deletions
+9
View File
@@ -1135,9 +1135,18 @@ async def ws_fx_realtime(websocket: WebSocket, session_id: str):
_pf.write("%d pump_start\n" % int(_time.time() * 1000))
_last_lat = None
_last_proc = None
_hb_last = _time.time()
try:
while True:
try:
# V46: heartbeat — mỗi ~100ms; gap giữa 2 pump_hb liên tiếp
# > 300ms = event loop engine bị freeze (cause toàn cục stall
# cả 2 session — bridge idle chờ input). Phân biệt với client
# stall (wl_gap/main_in_gap) và bridge stall (pump_gap).
_hb_now = _time.time()
if _pf is not None and (_hb_now - _hb_last) >= 0.1:
_hb_last = _hb_now
_pf.write("%d pump_hb" % int(_hb_now * 1000) + chr(10))
sess.flush_input_stale() # input lẻ kẹt trong pending → publish
_lats = sess.get_latencies()
_total = sum(_lats.values()) if _lats else 0