Repository navigation
[data][actor-only][1/n] Add resource bank - #67697
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new ResourceBank for per-dataset object-store accounting in the actor-only streaming executor, integrating it across various operators and the streaming executor itself to track live and cumulative object store usage, prebuffered outputs, and cross-node transfers. It also refactors BlockMetadata and BlockStats to track node and actor IDs directly. A high-severity issue was found in actor_pool_map_operator.py where bm.size_bytes could be None, potentially causing a TypeError when added to remote_bytes. A code suggestion was provided to safely handle this with a fallback value.
| for bm in bundle.metadata: | ||
| producer_node_id = bm.node_id | ||
| if producer_node_id is not None and producer_node_id != actor_node_id: | ||
| remote_bytes += bm.size_bytes | ||
| remote_blocks += 1 |
There was a problem hiding this comment.
In actor_pool_map_operator.py, bm.size_bytes is of type Optional[int] and can be None. Adding bm.size_bytes directly to remote_bytes without a fallback or null check will raise a TypeError and crash the executor if any block has None size metadata. Please use bm.size_bytes or 0 to safely handle None values.
| for bm in bundle.metadata: | |
| producer_node_id = bm.node_id | |
| if producer_node_id is not None and producer_node_id != actor_node_id: | |
| remote_bytes += bm.size_bytes | |
| remote_blocks += 1 | |
| for bm in bundle.metadata: | |
| producer_node_id = bm.node_id | |
| if producer_node_id is not None and producer_node_id != actor_node_id: | |
| remote_bytes += bm.size_bytes or 0 | |
| remote_blocks += 1 |
e91caba to
77c4e75
Compare
| "the output was still in flight)." | ||
| ) | ||
| else: | ||
| actor_info.live.on_output_consumed(bm=bm) |
There was a problem hiding this comment.
Downscale consume drops remaining outputs
Medium Severity
After to_downscaled zeros an actor's pulled-output counters, on_output_consumed still decrements that actor whenever the count is non-zero. A later consume of a pre-downscale block (already dropped from the actor) subtracts from post-downscale outputs that are still live, so the actor under-reports remaining object-store use.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 77c4e75. Configure here.
There was a problem hiding this comment.
I don't think this is an issue, if an actor downscaled, no in flight tasks are alive
77c4e75 to
178fdf2
Compare
| out_metadata.append(metadata) | ||
| self._output_blocks_stats.append(metadata.to_stats()) | ||
| out_metadata.append(sliced_metadata) | ||
| self._output_blocks_stats.append(sliced_metadata.to_stats()) |
There was a problem hiding this comment.
Limit drops blocks without bank withdraw
Medium Severity
When LimitOperator hits the row limit mid-bundle, it withdraws only the block it sliced. Remaining unread blocks in that bundle are dropped and never sent through on_block_consumed, so they stay in ResourceBank as live outputs that will never drain.
Reviewed by Cursor Bugbot for commit 178fdf2. Configure here.
## Overview Adds a resource bank component to track object store usage of actors. It can be tracked through multiple ways - per actor - per operator - per node - per node, operator The APIs exposed are in the ResourceBankBase class. This class defines the methods with which an actor pool map operator needs to call to get accurate resource accounting. Some may notice this as similar to op runtime metrics -- I have duplicated the APIs since we still need op run time metrics for backwards compatibility, and since there was a lot of experimentation, didn't want to maintain op runtime metrics. ## Usage None at the moment, it is just the wiring. The usage will come after we finalize the sizer implementation, in later PRs of this stack. ## Additional Info ResourceBank component can only be used when `RAY_DATA_ACTOR_ONLY_BACKEND=1`. Currently, this flag is off by default. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: iamjustinhsu <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
178fdf2 to
7c299ab
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
❌ 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 7c299ab. Configure here.
| left, right, left_meta_ref, right_meta_ref = split_single_block.options( | ||
| **options | ||
| ).remote(b, metadata, left_size) | ||
| left_meta, right_meta = ray.get([left_meta_ref, right_meta_ref]) |
There was a problem hiding this comment.
Split path blocks the scheduler
Medium Severity
_split_block now waits on ray.get for split metadata on every backend. Mid-block splits run on the streaming executor thread, so the scheduler stalls until the remote slice finishes instead of only holding the new block refs. That loses overlap with other operators and can hang the whole pipeline if the slice task is slow or stuck.
Reviewed by Cursor Bugbot for commit 7c299ab. Configure here.
…or pools (#67698) ## Summary When the actor-only backend is on, promote every `TaskPoolStrategy` map operator to an equivalent `ActorPoolStrategy` in `MapOperator.create`. The helper (`maybe_promote_compute_strategy`) is self-gated and does nothing when the flag is off. Part 2 of 12 of the Ray Data actor-only backend stack. Stacked on #67697; review only the top commit. Everything here is gated behind `RAY_DATA_ACTOR_ONLY_BACKEND` (off by default) unless noted under **After**. ## Before Map operators with a function UDF (or an explicit `TaskPoolStrategy`) run as `TaskPoolMapOperator`s. `get_compute_strategy` rejects a plain function paired with an explicit `ActorPoolStrategy`. ## After - Under the flag, the same operators become actor pools. - A plain function with an explicit `ActorPoolStrategy` is allowed, because that's how callers set pool size or prevent fusion. - ListFiles and Download plan the actor-pool variant and cap the pool at the real listing parallelism. - With the flag off, nothing changes. ```mermaid flowchart TD subgraph Before subgraph BS[Subsystem: physical planning] subgraph BC[Component: MapOperator.create] B1[TaskPoolStrategy] --> B2[TaskPoolMapOperator] end end end subgraph After subgraph AS[Subsystem: physical planning] subgraph AC[Component: MapOperator.create] A1[TaskPoolStrategy] --> A3["maybe_promote_compute_strategy (flag on)"] --> A2[ActorPoolMapOperator] end end end class A3 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 ``` ## Subsystems physical planning (behavioral change, flag-gated), API (`get_compute_strategy` validation) ## 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`: 44 passed. - `pytest python/ray/data/tests/test_actor_pool_map_operator.py unit/datasource_v2/test_list_files_op.py test_map.py test_map_operator.py test_combine_downloads.py`: 399 passed, 4 failed. The same 4 fail on 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](https://claude.com/claude-code) Signed-off-by: iamjustinhsu <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: sampan <[email protected]> Co-authored-by: Prasad Palkar <[email protected]>


Summary
Add
ResourceBank, which tracks the object-store usage of the actor-only backend's actors per actor, operator, node and (operator, node), and thread it throughPhysicalOperator.start(). This is wiring for later PRs: nothing reads the bank yet, and it only exists whenRAY_DATA_ACTOR_ONLY_BACKEND=1(off by default).Part 1 of 12 of the Ray Data actor-only backend stack. Based on master. Everything here is gated behind
RAY_DATA_ACTOR_ONLY_BACKEND(off by default) unless noted under After.Before
Operators get
start(options, block_ref_counter, lineage_tracker). Object-store usage is tracked only per operator (OpRuntimeMetrics). A block's producing node is read fromBlockMetadata.exec_stats.node_id, so blocks without exec stats (for exampleInputDataBufferinputs) report an unknown node.After
StreamingExecutorcreates aResourceBankand passes it to every operator throughstart(..., resource_bank=...).InputDataBufferandLimitOperatorregister the blocks they emit, so withdrawals match deposits. Consumers report consumed blocks fromget_output_blocking(), and the scheduling thread applies them.BlockMetadatacarriesnode_id(andBlockExecStatsan optionalactor_id). Locality and stats paths readmeta.node_id, so source-operator inputs now count as locality hits instead of misses (see thetest_statsexpectation changes). Map operators also record two new metrics:bytes_remote_inputs_readandnum_remote_blocks_read.flowchart TD subgraph Before subgraph BS[Subsystem: execution] subgraph BC[Component: StreamingExecutor] B1[build_streaming_topology] --> B2["op.start(options, ref_counter, lineage_tracker)"] end end subgraph BB[Subsystem: block] B3[exec_stats.node_id] end end subgraph After subgraph AS[Subsystem: execution] subgraph AC[Component: StreamingExecutor] A0["ResourceBank (flag on)"] --> A1[build_streaming_topology] --> A2["op.start(..., lineage_tracker, resource_bank)"] A4[InputDataBuffer / LimitOperator] -->|on_new_output| A0 end end subgraph AB[Subsystem: block] A3[BlockMetadata.node_id] end end class A0,A4 added class A2,A3 changed classDef removed fill:#ffcdd2,stroke:#c62828,color:#000 classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000 classDef changed fill:#fff9c4,stroke:#f9a825,color:#000Subsystems
execution (behavioral change, flag-gated), block / data format (
BlockMetadata.node_id, all backends), observability (new remote-read metrics; locality-hit accounting)Testing
Each run used a clean checkout of this branch. Any test that failed was rerun on unmodified
masterin 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: 41 passed.pytest python/ray/data/tests/test_stats.py test_split.py test_streaming_executor.py: no new failures vs master (20 environment failures fail identically on master). The 3test_statsfailures caused bynode_idmoving toBlockStatswere fixed in this PR's test helper; those tests now pass.pytest python/ray/data/tests/unit test_operators.py unit/test_limit_operator.py: 2054 passed, 11 failed. The same 11 fail on master.pre-commit runon changed files: clean.Notes
gh pr list --repo ray-project/ray --state open --search "actor-only").🤖 Generated with Claude Code