Skip to content

[data][actor-only][6/n] Scheduling loop + actor-only metrics [DO NOT MERGE] - #67702

Draft
iamjustinhsu wants to merge 6 commits into
masterfrom
iamjustinhsu/ao/06-scheduling-loop
Draft

iamjustinhsu wants to merge 6 commits into
masterfrom
iamjustinhsu/ao/06-scheduling-loop

Conversation

@iamjustinhsu

Copy link
Copy Markdown
Contributor

Summary

Add the actor-only backend's scheduling loop (an experimental streaming executor), its progress output, metrics and dashboard. This is the first PR where the flag actually switches backends; the operator sizer is a placeholder until the next PR.

Part 6 of 12 of the Ray Data actor-only backend stack. Stacked on #67701; review only the top commit. Everything here is gated behind RAY_DATA_ACTOR_ONLY_BACKEND (off by default) unless noted under After.

Before

With or without the flag, the classic StreamingExecutor loop drives execution. DataOpTask.on_data_ready takes a byte budget, and process_completed_tasks counts errored blocks in a nested closure.

After

  • With the flag on, an experimental executor drives each tick: refresh actors, pull outputs per actor, dispatch, then size (placeholder).
  • It reports actor-only metrics and dashboard panels, and uses a ResourceReporter view for the cluster utilization gauge.
  • Shared refactors that affect the classic path:
    • on_data_ready(max_to_read=TaskPullRequest, ...) returns a TaskPullResponse.
    • Error accounting moves into _handle_data_op_task_exception.
    • The progress bar asks the operator for its backpressure string.
    • OpState gets an index, and has_pending_bundles becomes has_pending_input_bundles.
flowchart TD
    subgraph Before
        subgraph BS[Subsystem: execution]
            subgraph BC[Component: streaming executor]
                B1[StreamingExecutor loop] --> B2["on_data_ready(max_bytes)"]
            end
        end
    end
    subgraph After
        subgraph AS[Subsystem: execution]
            subgraph AC[Component: streaming executor]
                A0{flag on?} -->|no| A1[StreamingExecutor loop]
                A0 -->|yes| A5["experimental scheduling loop: refresh -> pull -> dispatch -> size(placeholder)"]
                A1 --> A2["on_data_ready(TaskPullRequest)"]
                A5 --> A2
            end
        end
        subgraph AO[Subsystem: observability]
            A6[actor-only metrics + dashboard]
        end
    end
    class A0,A5,A6 added
    class A2 changed
    classDef removed fill:#ffcdd2,stroke:#c62828,color:#000
    classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000
    classDef changed fill:#fff9c4,stroke:#f9a825,color:#000
Loading

Implementation notes

The cluster utilization gauge now reads through a ResourceReporter protocol (get_global_usage, get_global_limits, is_blocked_on_consumer), so either backend can feed it. ActorOnlyResourceReporter.is_blocked_on_consumer() returns False: the actor-only backend doesn't track consumer blocking, so the autoscaler never skips a scale-up for it.

Subsystems

execution (behavioral change, flag-gated; classic path gets the mechanical TaskPullRequest / error-accounting refactor), resource allocation (utilization gauge input), observability

Testing

Each run used a clean checkout of this branch. Any test that failed was rerun on unmodified master in the same environment; only failures that pass on master count as regressions.

  • RAY_DATA_ACTOR_ONLY_BACKEND=1 pytest python/ray/data/tests/actor_only: 176 passed.
  • pytest python/ray/data/tests/test_streaming_executor.py: 57 passed.
  • pytest python/ray/data/tests/test_lineage_reconstruction.py: 30 passed.
  • pytest python/ray/data/tests/test_default_cluster_autoscaler_v2.py: 41 passed.
  • pytest python/ray/data/tests/test_actor_autoscaler.py test_issue_detection_manager.py unit/test_deduping_schema.py test_rate_based_cluster_autoscaler.py test_resource_manager.py test_progress_manager.py test_map.py: no new failures vs master.
  • pre-commit run on changed files: clean.

Notes

  • Not a duplicate: no open ray-project/ray PR covers the actor-only backend (checked with gh pr list --repo ray-project/ray --state open --search "actor-only").
  • AI assistance (Claude Code) was used for this change. I have reviewed every changed line.

🤖 Generated with Claude Code

@iamjustinhsu
iamjustinhsu added this pull request to stack #67709 November 2, 2026 21:02
@iamjustinhsu
iamjustinhsu removed this pull request from stack #67709 November 2, 2026 21:05
@iamjustinhsu
iamjustinhsu added this pull request to stack #67710 November 2, 2026 21:05
@iamjustinhsu
iamjustinhsu marked this pull request as ready for review November 2, 2026 21:15
@iamjustinhsu
iamjustinhsu requested review from a team as code owners November 2, 2026 21:15
@iamjustinhsu iamjustinhsu added the go add ONLY when ready to merge, run all tests label Nov 2, 2026

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

Copy link
Copy Markdown
Contributor

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 introduces an experimental 'actor-only' backend for Ray Data's streaming executor, designed to improve performance and resource management by utilizing a pull-based dispatch model and a centralized resource reporter. Key changes include the introduction of an OperatorSizer for actor pool management, a deadlock escape hatch for output limits, and comprehensive new Prometheus metrics for monitoring the actor-only backend. I have reviewed the changes and identified two critical issues: an unsafe assert in the metrics accounting that could crash the executor, and an IndexError risk in the input-moving logic for multi-input operators. Please address these before merging.

)
freed_bytes = cumulative.output_bytes.sum - live_pulled_bytes
freed_blocks = cumulative.output_bytes.num_samples - live_pulled_blocks
assert freed_bytes >= 0 and freed_blocks >= 0, (freed_bytes, freed_blocks)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Using an assert statement here can crash the entire dataset execution in production if there is any slight mismatch or floating-point precision issue in metrics accounting. Metrics should be robust and best-effort, and should never crash the main execution loop. It is much safer to clamp the values to 0.0 instead of asserting.

Suggested change
assert freed_bytes >= 0 and freed_blocks >= 0, (freed_bytes, freed_blocks)
freed_bytes = max(0.0, freed_bytes)
freed_blocks = max(0.0, freed_blocks)

# A completed operator (e.g. an early-finishing limit) must not be fed
# further inputs.
if not op.has_completed():
while op_state.has_pending_input_bundles():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

op_state.has_pending_input_bundles() returns True if any input queue has bundles. However, move_input_into_op() pops from all input queues. For multi-input operators (such as Zip or Union), if the queues are unbalanced, this will cause an IndexError when popping from an empty queue, crashing the executor. To support multi-input operators robustly, we should only move inputs when all input queues have pending bundles.

Suggested change
while op_state.has_pending_input_bundles():
while op_state.input_queues and all(len(q) > 0 for q in op_state.input_queues):

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@ray-gardener ray-gardener Bot added the data Ray Data-related issues label Nov 3, 2026
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/06-scheduling-loop branch from e747867 to 903e436 Compare November 3, 2026 20:09

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

limits = ExecutionResources.zero()
for bundle in self._autoscaling_coordinator.get_reserved_resources().values():
limits = limits.add(ExecutionResources.from_resource_dict(bundle))
return limits

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Object store limits stay at zero

Medium Severity

get_global_limits only sums coordinator reserved bundles. Those bundles carry CPU, GPU, and heap memory, not object_store_memory, so the object-store limit stays 0. The utilization gauge then divides live bank usage by 0 and records 0% object-store utilization, so the autoscaler never scales on object-store pressure and the cluster panel stays flat.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 903e436. Configure here.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/06-scheduling-loop branch 3 times, most recently from 817c36b to 24e6a10 Compare November 6, 2026 00:57

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/06-scheduling-loop branch from a4a17e7 to d87a015 Compare November 6, 2026 20:34

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/06-scheduling-loop branch from d87a015 to ae31d17 Compare November 10, 2026 19:01

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/06-scheduling-loop branch from ae31d17 to 2d8d7bb Compare November 10, 2026 21:09

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/06-scheduling-loop branch from 2d8d7bb to 61dc113 Compare November 12, 2026 17:04

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/06-scheduling-loop branch 2 times, most recently from 89f39fd to 4890fd0 Compare November 13, 2026 22:36
Comment on lines +433 to +434
freed_bytes = max(0.0, freed_bytes)
freed_blocks = max(0, freed_blocks)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Should we have an assertion here, if it is unexpected behaviour for freed_bytes and freed_blocks to be negative?

Could help us catch bugs / reason about failures.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/06-scheduling-loop branch from 4890fd0 to 0930246 Compare November 19, 2026 00:41
@richardliaw
richardliaw force-pushed the iamjustinhsu/ao/06-scheduling-loop branch from 0930246 to 4f69fb0 Compare November 19, 2026 19:52
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/06-scheduling-loop branch 2 times, most recently from 0930246 to 02be313 Compare November 19, 2026 20:55
Base automatically changed from iamjustinhsu/ao/05-actor-pool-op to master November 19, 2026 23:23
- adds a new experimental scheduling executor + progress logs + metrics
+ dashboard which will be used when actor only backend is enabled.
- adds placeholders for the operator sizer which will be filled in in
the next pr in the stack

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
Co-authored-by: sampan <[email protected]>
Co-authored-by: Prasad Palkar <[email protected]>
@richardliaw
richardliaw force-pushed the iamjustinhsu/ao/06-scheduling-loop branch from 02be313 to 351c107 Compare November 19, 2026 23:23
Signed-off-by: iamjustinhsu <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 13003f7. Configure here.

rows_per_bundle = max(1, self._buffer.num_rows() // max(1, len(self._buffer)))
locality_rows = math.ceil(self._max_buffer_size) * rows_per_bundle
equal_rows = self.num_output_splits() * rows_per_bundle if self._equal else 0
return max(locality_rows, equal_rows)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Splitter row estimate defaults to one

Low Severity

OutputSplitter.min_num_rows_needed_to_make_progress uses average rows per buffered bundle, and when the buffer is empty that average collapses to 1. The escape hatch then treats num_output_splits (or _max_buffer_size) rows as enough for an equal or locality split. Real bundles are typically thousands of rows, so a backpressured producer holding less than a split's worth of data can look un-starved and the hatch never raises the output limit.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 13003f7. Configure here.

Signed-off-by: iamjustinhsu <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
@iamjustinhsu
iamjustinhsu marked this pull request as draft November 21, 2026 01:04
@iamjustinhsu iamjustinhsu changed the title [data][actor-only][6/n] Scheduling loop + actor-only metrics [data][actor-only][6/n] Scheduling loop + actor-only metrics [DO NOT MERGE] Nov 21, 2026
interfaces/common.py keeps both sides' type aliases: this branch's
PlacementGroupIdStr and master's OperatorId and TaskIndex (#68400).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants