-
Notifications
You must be signed in to change notification settings - Fork 87
a5 host_build_graph: shrink ready-queue capacity 65536 -> 8192 + graph_ready safe-fail #1773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -489,26 +489,27 @@ struct PTO2SchedulerState { | |
| // the per-shape ready_sync_queues[] (drained as Tier-0); everything else to | ||
| // ready_queues[]. | ||
| void push_ready_routed(PTO2TaskSlotState *slot_state) { | ||
| if (slot_state->task_kind == TaskKind::GRAPH) { | ||
| graph_ready_queue.push(slot_state); | ||
| return; | ||
| } | ||
| PTO2ResourceShape shape = slot_state->active_mask.to_shape(); | ||
| bool pushed; | ||
| if (shape == PTO2ResourceShape::DUMMY || | ||
| (slot_state->task_attrs.has_predicate() && !slot_state->payload->predicate.pass())) { | ||
| pushed = dummy_ready_queue.push(slot_state); | ||
| } else if (slot_state->task_attrs.requires_sync_start()) { | ||
| pushed = ready_sync_queues[static_cast<int32_t>(shape)].push(slot_state); | ||
| if (slot_state->task_kind == TaskKind::GRAPH) { | ||
| pushed = graph_ready_queue.push(slot_state); | ||
| } else { | ||
| pushed = ready_queues[static_cast<int32_t>(shape)].push(slot_state); | ||
| PTO2ResourceShape shape = slot_state->active_mask.to_shape(); | ||
| if (shape == PTO2ResourceShape::DUMMY || | ||
| (slot_state->task_attrs.has_predicate() && !slot_state->payload->predicate.pass())) { | ||
| pushed = dummy_ready_queue.push(slot_state); | ||
| } else if (slot_state->task_attrs.requires_sync_start()) { | ||
| pushed = ready_sync_queues[static_cast<int32_t>(shape)].push(slot_state); | ||
| } else { | ||
| pushed = ready_queues[static_cast<int32_t>(shape)].push(slot_state); | ||
| } | ||
| } | ||
|
Comment on lines
+493
to
505
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -u
rg -n -C 8 -P '\bgraph_prepare_queue\b' src/a5/runtime/host_build_graphRepository: hw-native-sys/simpler Length of output: 16999 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' '--- queue implementation and error constants ---'
rg -n -C 10 'struct PTO2ReadyQueue|class PTO2ReadyQueue|bool push|push_tagged|PTO2_ERROR_READY_QUEUE_OVERFLOW|ready_queue_capacity' \
src/a5/runtime/host_build_graph/runtime
printf '%s\n' '--- graph preparation call sites ---'
rg -n -C 14 'graph_prepare_queue\.(push|push_tagged)|while \(!sched_->graph_prepare_queue' \
src/a5/runtime/host_build_graph/runtime
printf '%s\n' '--- scheduler error consumption and queue sizing ---'
rg -n -C 8 'sched_error_code|PTO2_READY_QUEUE_SIZE|off_graph_prepare_queue_slots|ready_queue_capacity' \
src/a5/runtime/host_build_graph/runtime/scheduler \
src/a5/runtime/host_build_graph/runtime/sharedRepository: hw-native-sys/simpler Length of output: 50377 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' '--- PTO2ReadyQueue push semantics ---'
sed -n '63,152p' src/a5/runtime/host_build_graph/runtime/scheduler/pto_scheduler.h
printf '%s\n' '--- graph preparation control flow ---'
sed -n '1118,1160p' src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_cold_path.cpp
sed -n '1288,1365p' src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_dispatch.cpp
printf '%s\n' '--- queue consumers and scheduler stop behavior ---'
rg -n -C 6 'graph_prepare_queue\.pop|sched_error_code\.load|completed_\.load|PTO2_ERROR_READY_QUEUE_OVERFLOW' \
src/a5/runtime/host_build_graph/runtime/schedulerRepository: hw-native-sys/simpler Length of output: 26385 Retain the overflow-handling concern for Both 🤖 Prompt for AI Agents |
||
| // A queue is sized for the whole task window and each task is routed to one | ||
| // queue exactly once, so push cannot legitimately fail. A false return means | ||
| // the target slot fell outside the shipped prefix, or the window genuinely | ||
| // exceeds queue capacity — either way the task is dropped and the run would | ||
| // otherwise stall. Latch a named error so it surfaces as READY_QUEUE_OVERFLOW | ||
| // rather than an anonymous forward-progress timeout. | ||
| // Every ready / sync / dummy / graph task routes to exactly one queue. A | ||
| // false push means that queue's peak concurrent occupancy exceeded | ||
| // PTO2_READY_QUEUE_SIZE — a capacity mis-sizing, not a normal condition. | ||
| // Silently dropping the task would stall the run, so latch a named error | ||
| // (surfaces as READY_QUEUE_OVERFLOW rather than an anonymous | ||
| // forward-progress timeout). The graph_ready push is checked identically | ||
| // so a graph task cannot be dropped either. | ||
| if (!pushed) { | ||
| int32_t expected = PTO2_ERROR_NONE; | ||
| sm_header->sched_error_code.compare_exchange_strong( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Document the graph queues in the capacity contract.
PTO2_READY_QUEUE_SIZEalso sizesgraph_ready_queueandgraph_prepare_queueinsrc/a5/runtime/host_build_graph/runtime/shared/pto_runtime2_init.cpp:104-124. Lines 99-100 list only ready, sync, and dummy queues. The “per-shape” description also omits graph queues. Name all queues that use this capacity and state which insertion paths latchPTO2_ERROR_READY_QUEUE_OVERFLOW.🤖 Prompt for AI Agents
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: hw-native-sys/simpler
Length of output: 247
🏁 Script executed:
Repository: hw-native-sys/simpler
Length of output: 1347
🏁 Script executed:
Repository: hw-native-sys/simpler
Length of output: 7266
🏁 Script executed:
Repository: hw-native-sys/simpler
Length of output: 50377
Keep the a5 and a2a3 mirror headers byte-for-byte identical.
The queue definition and scheduler region match. The headers still differ in include guards, comments, and trailing
#endif; these files are not documented exceptions.🤖 Prompt for AI Agents
Source: Learnings