perf(agent,gateway): back cancel-wait polls off from 1ms to 25ms (re-review #5)
The fence-cancel poll loops (sync host wait in conversation_compression, async hygiene wait in gateway/run) spun at 1kHz while the worker held the fence through its lock-setup window — which rides SessionDB write patience and can last seconds. 25ms keeps sub-tick cancel latency without the spin.
This commit is contained in:
@@ -972,7 +972,12 @@ def run_compress_context_with_progress_timeout(
|
||||
break
|
||||
cancelled = fence.try_cancel_before_commit()
|
||||
if cancelled is None:
|
||||
time.sleep(0.001)
|
||||
# Round-2 #5: the fence is only held transiently here (lock
|
||||
# setup / cancel admission — an in-flight commit is caught by
|
||||
# the commit_in_flight check above), but that window rides
|
||||
# SessionDB write patience and can last seconds. 25ms keeps
|
||||
# sub-tick latency without a 1kHz spin.
|
||||
time.sleep(0.025)
|
||||
if not cancelled:
|
||||
# Pre-commit ceiling already elapsed, but begin_commit() won the
|
||||
# race. Waiting is intentional: SessionDB mutation cannot be
|
||||
|
||||
+6
-1
@@ -16747,7 +16747,12 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew
|
||||
_hyg_commit_fence.try_cancel_before_commit()
|
||||
)
|
||||
if _cancelled is None:
|
||||
await asyncio.sleep(0.001)
|
||||
# Round-2 #5: transient
|
||||
# lock-setup windows ride
|
||||
# write patience for seconds;
|
||||
# 25ms keeps sub-tick latency
|
||||
# without 1kHz spin.
|
||||
await asyncio.sleep(0.025)
|
||||
if not _cancelled:
|
||||
# The worker crossed the commit boundary just
|
||||
# before the timeout. The fence poll waited for
|
||||
|
||||
Reference in New Issue
Block a user