[PR #4738] [Engine] avoid lost control-queue wakeups #5155

Open
opened 2026-11-07 16:33:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4738
Author: @NektoDron
Created: 10/30/2026
Status: 🔄 Open

Base: main ← Head: fix-control-notify


📝 Commits (1)

  • bd58e83 serve: avoid lost control-queue wakeups

📊 Changes

2 files changed (+267 additions, -1 deletions)

View changed files

📝 serve/server.py (+11 -1)
➕ serve/test_control_notify.py (+256 -0)

📄 Description

Problem and result

A control-queue waiter can read an ineligible fairness/order predicate, release slot_cv, and miss a notification sent before it enters Condition.wait(). It then enters the 0.5-second timeout wait even though it can proceed. Removing a cancelled or closed waiter can also make another waiter eligible without notifying it.

The regression tests reproduce these schedules deterministically against the actual unpatched _take_control method. The fix checks eligibility again under the condition lock before waiting and notifies when removal changes eligibility.

None. This is a focused queue-notification fix; it does not change the service FIFO or admission policy.

Approach

Recheck both epoch/waiter fairness and STRATA_ADMIT_SHORT_FIRST arbitration. Removing an ordered request can select a new winner even when more than one waiter remains, so that removal also notifies the condition. Keep the existing lock-acquisition recheck, cancellation handling, queue deadlines and heartbeat behavior.

Validation

Passed:

  • Linux, Python 3.14, base 870aedd9e1ebe1c91f94da93b59af17729f6c5c0 plus this patch: python3 -m unittest serve.test_control_notify -v — 15 deterministic tests passed, without a GPU, process or wall-clock sleeps. They cover the check/wait gap, cancellation/close cleanup, three-waiter short-first handoff, a shorter arrival during acquire, restart/death and queue deadlines before/after acquisition.

  • Negative control with the final tests and the exact upstream method: six intended race assertions fail; the other nine tests pass. The final fixed method passes all fifteen.

  • python3 -m unittest serve.test_control_notify serve.test_admit_order serve.test_queue_keepalive serve.test_parallel_yield serve.test_control_cancel serve.test_quiet_cancel serve.test_vision_busy serve.test_parallel -v — all 75 tests passed in 93.913 seconds on the same patched base (Python 3.14.4). These use mock engines/HTTP services, not a GPU model.

  • python3 -m py_compile serve/server.py serve/test_control_notify.py and git diff --check — passed.

  • Independent focused rerun on Python 3.12.14: all 15 notification tests passed.

Failed:

  • The unpatched negative control fails the six race regressions, as expected. No failure observed in the fixed focused tests.

Not run:

  • GPU/model execution and end-to-end latency measurements. This patch changes only Python queue synchronization; no native CUDA, HIP, SYCL or Metal files change and no native builds were run.

Limits

These tests establish the notification schedules and preserve short-first/deadline behavior. They do not establish a model TTFT improvement or a general latency bound, and do not address unrelated FIFO/socket stalls.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4738 **Author:** [@NektoDron](https://github.com/NektoDron) **Created:** 10/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-control-notify` --- ### 📝 Commits (1) - [`bd58e83`](https://github.com/Niko1221/Strata/commit/bd58e834c445f6f8696df8fcf23c0be4a6711d68) serve: avoid lost control-queue wakeups ### 📊 Changes **2 files changed** (+267 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+11 -1) ➕ `serve/test_control_notify.py` (+256 -0) </details> ### 📄 Description ## Problem and result A control-queue waiter can read an ineligible fairness/order predicate, release `slot_cv`, and miss a notification sent before it enters `Condition.wait()`. It then enters the 0.5-second timeout wait even though it can proceed. Removing a cancelled or closed waiter can also make another waiter eligible without notifying it. The regression tests reproduce these schedules deterministically against the actual unpatched `_take_control` method. The fix checks eligibility again under the condition lock before waiting and notifies when removal changes eligibility. ## Related discussion None. This is a focused queue-notification fix; it does not change the service FIFO or admission policy. ## Approach Recheck both epoch/waiter fairness and `STRATA_ADMIT_SHORT_FIRST` arbitration. Removing an ordered request can select a new winner even when more than one waiter remains, so that removal also notifies the condition. Keep the existing lock-acquisition recheck, cancellation handling, queue deadlines and heartbeat behavior. ## Validation **Passed:** - Linux, Python 3.14, base `870aedd9e1ebe1c91f94da93b59af17729f6c5c0` plus this patch: `python3 -m unittest serve.test_control_notify -v` — 15 deterministic tests passed, without a GPU, process or wall-clock sleeps. They cover the check/wait gap, cancellation/close cleanup, three-waiter short-first handoff, a shorter arrival during acquire, restart/death and queue deadlines before/after acquisition. - Negative control with the final tests and the exact upstream method: six intended race assertions fail; the other nine tests pass. The final fixed method passes all fifteen. - `python3 -m unittest serve.test_control_notify serve.test_admit_order serve.test_queue_keepalive serve.test_parallel_yield serve.test_control_cancel serve.test_quiet_cancel serve.test_vision_busy serve.test_parallel -v` — all 75 tests passed in 93.913 seconds on the same patched base (Python 3.14.4). These use mock engines/HTTP services, not a GPU model. - `python3 -m py_compile serve/server.py serve/test_control_notify.py` and `git diff --check` — passed. - Independent focused rerun on Python 3.12.14: all 15 notification tests passed. **Failed:** - The unpatched negative control fails the six race regressions, as expected. No failure observed in the fixed focused tests. **Not run:** - GPU/model execution and end-to-end latency measurements. This patch changes only Python queue synchronization; no native CUDA, HIP, SYCL or Metal files change and no native builds were run. ## Limits These tests establish the notification schedules and preserve short-first/deadline behavior. They do not establish a model TTFT improvement or a general latency bound, and do not address unrelated FIFO/socket stalls. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5155
No description provided.