Skip to content

Refactor: drop unused READY/RUNNING task states#770

Merged
jvjhfhg merged 1 commit into
mainfrom
refactor/drop-unused-ready-running-task-states
May 13, 2026
Merged

Refactor: drop unused READY/RUNNING task states#770
jvjhfhg merged 1 commit into
mainfrom
refactor/drop-unused-ready-running-task-states

Conversation

@poursoul
Copy link
Copy Markdown
Collaborator

Summary

The PTO2TaskState enum advertised the chain
PENDING → READY → RUNNING → COMPLETED → CONSUMED, but in practice:

  • PTO2_TASK_RUNNING was never written or read anywhere in src/.
  • PTO2_TASK_READY was written by a single CAS in the profiling-instrumented
    release_fanin_and_check_ready and had no readers. The fanin_refcount.fetch_add already elects a unique winner for the ready-queue push, so the CAS was redundant; the non-profiling overload had already been doing this without writing task_state.

The actual transitions performed by the runtime are
PENDING → COMPLETED → CONSUMED; ready-vs-running is derived from
fanin_refcount / per-core running_slot_state, not from task_state.

Changes

  • Drop PTO2_TASK_READY and PTO2_TASK_RUNNING; renumber the enum to
    PENDING(0) / COMPLETED(1) / CONSUMED(2). The < / >= PTO2_TASK_COMPLETED
    ordering comparisons in scheduler/orchestrator still hold under the new
    numbering since CONSUMED remains the largest value.
  • Drop the redundant CAS PENDING → READY in the profiling-instrumented
    release_fanin_and_check_ready so it matches the non-profiling path.
  • Delete the unused task_state_name() helper (no callers in repo).
  • Update scheduler_cold_path stall-dump comment to reflect that task_state
    has no intermediate ready/running value.
  • Update unit tests to use PENDING in place of READY/RUNNING fixtures
    (semantically equivalent: anything < COMPLETED).
  • Sync state-machine docs: docs/orchestrator.md, docs/scheduler.md, and
    src/{a2a3,a5}/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md.

Applied to both a2a3 and a5 runtime copies.

Test plan

  • cmake --build build/ut_cpp --target test_scheduler_state test_task_state test_wiring
  • ctest -R 'scheduler_state|task_state|wiring' — 3/3 pass
  • rg 'PTO2_TASK_(READY|RUNNING)|task_state_name' — zero hits across src/, tests/, docs/

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies the task state machine by removing the explicit READY and RUNNING states from the PTO2TaskState enumeration. Tasks now remain in the PENDING state from submission through dispatch until they reach the COMPLETED state. Readiness is now determined by fanin_refcount, and the running status is tracked via per-core pointers. The changes include updates to documentation, the scheduler logic, and unit tests to align with this streamlined lifecycle. I have no feedback to provide.

The PTO2TaskState enum advertised the chain
PENDING -> READY -> RUNNING -> COMPLETED -> CONSUMED, but RUNNING was
never written or read in src/ and READY was written by a single CAS in
release_fanin_and_check_ready with no readers. The fetch_add already
elects a unique winner for the queue push, so the CAS was redundant.

- Drop PTO2_TASK_READY and PTO2_TASK_RUNNING; renumber the enum to
  PENDING(0) / COMPLETED(1) / CONSUMED(2). The < / >= COMPLETED
  comparisons in scheduler/orchestrator still hold under the new
  numbering since CONSUMED remains the largest value.
- Drop the redundant CAS PENDING->READY in the profiling-instrumented
  release_fanin_and_check_ready so it matches the non-profiling path.
- Delete the unused task_state_name() helper (no callers in repo).
- Update scheduler_cold_path stall-dump comment to reflect that
  task_state has no intermediate values.
- Update unit tests to use PENDING in place of READY/RUNNING fixtures
  (semantically equivalent: anything < COMPLETED).
- Sync docs/orchestrator.md and docs/scheduler.md state machines.

Run on a2a3 ut-cpp: test_scheduler_state, test_task_state, test_wiring
all pass.
@poursoul poursoul force-pushed the refactor/drop-unused-ready-running-task-states branch from 1557539 to 3411163 Compare May 13, 2026 08:14
@jvjhfhg jvjhfhg merged commit ed00f24 into main May 13, 2026
14 checks passed
@poursoul poursoul deleted the refactor/drop-unused-ready-running-task-states branch May 13, 2026 08:47
@poursoul poursoul restored the refactor/drop-unused-ready-running-task-states branch May 13, 2026 08:47
@poursoul poursoul deleted the refactor/drop-unused-ready-running-task-states branch May 13, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants