Skip to content

[Data] [8/11] Tune Parquet reader IO threads and Arrow pool sizing - #65806

Merged
goutamvenkat-anyscale merged 2 commits into
ray-project:masterfrom
goutamvenkat-anyscale:goutam/data-parquet-reader-io-tuning
Aug 31, 2026
Merged

goutamvenkat-anyscale merged 2 commits into
ray-project:masterfrom
goutamvenkat-anyscale:goutam/data-parquet-reader-io-tuning

Conversation

@goutamvenkat-anyscale

@goutamvenkat-anyscale goutamvenkat-anyscale commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Why

Two independent throughput knobs for the Parquet read task, kept out of the footer-indexer PR because each changes behavior on its own and needs its own justification.

One reader thread per fragment, instead of capping at 4. The cap existed because the blind ParquetFileChunker could put an unbounded number of row groups — and therefore fragments — in a single read task, so an uncapped thread pool was a real risk. Now that #65596 has landed, read units are bin-packed to a byte budget, so the fragment count per task is bounded by construction and the cap only serializes IO that could overlap.

Size Arrow's IO/CPU pools for the read task. Arrow's defaults (~num cores, 8 IO threads) throttle the concurrent column/range fetches a Parquet scan issues against S3. That hurts most for row-group-scoped fragments, which is exactly what the footer path now produces.

Flow

No structural change — both are sizing knobs on the existing read path:

ReadFiles task
  ├─ pa.set_io_thread_count / set_cpu_count   ← new, at reader construction
  └─ _read_fragment_batches
       └─ num_workers = len(fragments)        ← was min(4, len(fragments))

The sequential path still applies when DataContext.execution_options.preserve_order is set, unchanged.

What changed

File Change
readers/file_reader.py Drop _DEFAULT_NUM_THREADS / RAY_DATA_READ_FILES_NUM_THREADS; num_workers = len(fragments_with_offsets). Also fixes the _read_fragment_batches docstring, which still documented the removed env var.
readers/parquet_file_reader.py pa.set_io_thread_count() / pa.set_cpu_count() at reader construction, from RAY_DATA_PARQUET_READER_IO_THREAD_COUNT / RAY_DATA_PARQUET_READER_CPU_COUNT (default 128 each; 0 disables).

Two things worth a careful look:

  • This removes RAY_DATA_READ_FILES_NUM_THREADS. It is undocumented and internal, but anyone setting it loses the knob.
  • pa.set_io_thread_count / set_cpu_count mutate process-global Arrow state from a constructor. That is deliberate — the read task is the process — but it means a non-Parquet reader sharing the worker sees the same pools.

Stack

Step 8 of an 11-step split of #64985.

Remaining after this: release-test tuning, then flipping the default and deleting the old chunker.

Two independent throughput knobs for the read task, kept out of the footer
feature PR because both change behavior on their own and need their own
justification.

- One reader thread per fragment instead of capping at 4
  (`RAY_DATA_READ_FILES_NUM_THREADS`). The cap was there because the blind
  chunker could put an unbounded number of fragments in one task; footer
  bins are size-bounded, so the fragment count per task now is too, and the
  cap just serializes IO that could overlap. Note this removes the env var,
  and the sequential path still applies when `preserve_order` is set.
- Size Arrow's process-wide IO/CPU pools from the reader ctor
  (default 128 each). Arrow's defaults (~num cores, 8 IO threads) throttle
  the concurrent column/range fetches a Parquet scan issues against S3,
  which hurts most for row-group-scoped fragments. These are
  `pa.set_io_thread_count` / `pa.set_cpu_count`, i.e. **process-global**
  state set from a constructor -- worth a careful look.

Signed-off-by: Goutam <[email protected]>
@goutamvenkat-anyscale goutamvenkat-anyscale added data Ray Data-related issues go add ONLY when ready to merge, run all tests labels Aug 31, 2026
@goutamvenkat-anyscale
goutamvenkat-anyscale marked this pull request as ready for review August 31, 2026 17:52
@goutamvenkat-anyscale
goutamvenkat-anyscale requested a review from a team as a code owner August 31, 2026 17:52

@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 removes the default thread limit for reading file fragments concurrently and introduces configurable Arrow process-wide IO and CPU thread pool counts for Parquet file reading. The review feedback highlights two critical issues: first, uncapped thread creation based on the number of fragments can lead to resource exhaustion, so a reasonable cap should be maintained; second, configuring Arrow's thread pools in the constructor only affects the driver process, so these settings should be applied lazily inside the read method on the worker processes where execution actually occurs.

return

num_workers = min(_DEFAULT_NUM_THREADS, len(fragments_with_offsets))
num_workers = len(fragments_with_offsets)

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

Uncapped thread creation can lead to process crashes or severe resource exhaustion. If a read task contains a large number of fragments (e.g., when reading many small files), setting num_workers = len(fragments_with_offsets) will cause make_async_gen to spawn an unbounded number of Python threads.

To prevent thread exhaustion and OSError: [Errno 11] Resource temporarily unavailable, please cap the maximum number of worker threads to a reasonable default (e.g., 16 or 32).

Suggested change
num_workers = len(fragments_with_offsets)
num_workers = min(len(fragments_with_offsets), 16)

Comment on lines +254 to 263
# Size Arrow's process-wide IO/CPU pools for the read task so a Parquet
# scan can issue many concurrent column/range fetches against S3 instead
# of being capped at Arrow's small default.
if _READER_IO_THREAD_COUNT > 0:
pa.set_io_thread_count(_READER_IO_THREAD_COUNT)
if _READER_CPU_COUNT > 0:
pa.set_cpu_count(_READER_CPU_COUNT)

@override
def _make_format(self) -> pds.ParquetFileFormat:

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

Configuring Arrow's process-wide thread pools in __init__ will only affect the driver/coordinator process where the ParquetFileReader is instantiated. Because ParquetFileReader is serialized and sent to worker processes for execution, and global C++ thread pool settings are not serialized, the worker processes will run with Arrow's default thread pool sizes (throttling concurrent fetches).

To ensure these performance tuning configurations are applied on the worker processes where the actual read tasks execute, please remove this configuration from __init__ and apply it lazily inside the read method on the worker.

Suggested change
# Size Arrow's process-wide IO/CPU pools for the read task so a Parquet
# scan can issue many concurrent column/range fetches against S3 instead
# of being capped at Arrow's small default.
if _READER_IO_THREAD_COUNT > 0:
pa.set_io_thread_count(_READER_IO_THREAD_COUNT)
if _READER_CPU_COUNT > 0:
pa.set_cpu_count(_READER_CPU_COUNT)
@override
def _make_format(self) -> pds.ParquetFileFormat:
@override
def read(self, input_split: FileManifest) -> Iterator[pa.Table]:
# Size Arrow's process-wide IO/CPU pools for the read task so a Parquet
# scan can issue many concurrent column/range fetches against S3 instead
# of being capped at Arrow's small default.
if _READER_IO_THREAD_COUNT > 0:
pa.set_io_thread_count(_READER_IO_THREAD_COUNT)
if _READER_CPU_COUNT > 0:
pa.set_cpu_count(_READER_CPU_COUNT)
return super().read(input_split)
@override
def _make_format(self) -> pds.ParquetFileFormat:

@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.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 2eef897. Configure here.

return

num_workers = min(_DEFAULT_NUM_THREADS, len(fragments_with_offsets))
num_workers = len(fragments_with_offsets)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Uncapped workers risk thread exhaustion

Medium Severity

Dropping the fragment-thread cap assumes footer bin-packing already bounds fragments per task, but that path is still behind RAY_DATA_PARQUET_ENABLE_FOOTER_INDEXER (default off). The default blind chunker still fans a chunk into one fragment per row group, and FileReader also serves non-Parquet formats, so num_workers can grow without bound and exhaust worker threads and memory.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2eef897. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm going to be enabling the footer indexer is the next PR

Comment on lines 253 to +260
)
# Size Arrow's process-wide IO/CPU pools for the read task so a Parquet
# scan can issue many concurrent column/range fetches against S3 instead
# of being capped at Arrow's small default.
if _READER_IO_THREAD_COUNT > 0:
pa.set_io_thread_count(_READER_IO_THREAD_COUNT)
if _READER_CPU_COUNT > 0:
pa.set_cpu_count(_READER_CPU_COUNT)

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.

While there is benefit of keeping the number of threads high for I/O work, what is the benefit of keeping the number of hardware threads this high? Maybe a more reasonable default would be the pyarrow default (which already checks the number of hardware threads in the system)
https://arrow.apache.org/docs/python/generated/pyarrow.cpu_count.html#pyarrow.cpu_count

@ayushk7102 ayushk7102 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.

LGTM, if we can set a more reasonable default for reader cpu count (i.e. 8 or number of hardware threads in system)

Signed-off-by: Goutam <[email protected]>
@goutamvenkat-anyscale
goutamvenkat-anyscale enabled auto-merge (squash) August 31, 2026 22:00
@goutamvenkat-anyscale
goutamvenkat-anyscale merged commit 8fe1e02 into ray-project:master Aug 31, 2026
7 checks passed
@goutamvenkat-anyscale
goutamvenkat-anyscale deleted the goutam/data-parquet-reader-io-tuning branch August 31, 2026 22:53
goutamvenkat-anyscale added a commit that referenced this pull request Sep 2, 2026
## Why

The last step of the split of #64985: flip Parquet V2 to the footer read
path, delete the blind one, and tune the release tests so this can be
validated by a real release run.

Everything it depends on has landed — footer types and the bin packer
(#65210), the `FooterReader` actor pool (#65273), the indexer plus
`count()` fix and packer-as-partitioner (#65596), reader IO tuning
(#65806), and test env pinning (#65169). The path has been reachable
behind `RAY_DATA_PARQUET_ENABLE_FOOTER_INDEXER` since #65596; this makes
it the only path.

## Flow

```mermaid
flowchart LR
  RP[read_parquet] --> FF["FooterFileIndexer<br/>+ OnlineBinPacker"]
  RP -.->|deleted| PC["ParquetFileChunker<br/>size-estimated chunks<br/>+ parquet_chunker_target_chunk_size"]
  style PC stroke-dasharray: 4 4
```

## What changed

**The flip** — `RAY_DATA_PARQUET_ENABLE_FOOTER_INDEXER` is gone from
both call sites. `_get_file_indexer()` always returns
`FooterFileIndexer`; `get_file_partitioner()` always returns
`OnlineBinPacker`.

**The deletions** — `ParquetFileChunker`, `ParquetFileChunkMetadata`,
`_calculate_row_group_range`, `_fragments_from_chunk_metadata`, and the
tests covering only that path.

**The config it left behind** —
`DataContext.parquet_chunker_target_chunk_size` and
`DEFAULT_PARQUET_CHUNKER_TARGET_CHUNK_SIZE` were read *only* by
`ParquetFileChunker.__init__`, so they would otherwise stay declared and
documented while doing nothing. Verified dead by grep across `.py` /
`.yaml` / `.rst` / `.md`.

**Reader pool defaults** — `RAY_DATA_PARQUET_READER_IO_THREAD_COUNT`
128, `RAY_DATA_PARQUET_READER_CPU_COUNT` 32.

## Release tests tuned

Budgets are per-test overrides of `RAY_DATA_PARQUET_BIN_PACKING_BYTES`
(uncompressed bytes of row-group data per read task; default 128 MiB).
The shape of the tuning: reads over few large groups want **large**
bins, because small bins shatter the read into short tasks the executor
cannot dispatch fast enough and the cluster idles; shuffle-bound reads
over many groups want **small** bins.

Rows whose variants all share the same tuning are collapsed and marked.

| release test | bin budget | other tuning |
| --- | --- | --- |
| `aggregate_groups_fixed_size_hash_shuffle_column02 column14` | 32 MiB
| — |
| `aggregate_groups_fixed_size_hash_shuffle_column08 column13 column14`
| 128 MiB | — |
| `aggregate_groups_fixed_size_shuffle_v2_column02 column14` | 64 MiB |
— |
| `aggregate_groups_fixed_size_shuffle_v2_column08 column13 column14` |
512 MiB | — |
| `aggregate_groups_fixed_size_sort_shuffle_pull_based_column02
column14` | 32 MiB | — |
| `aggregate_groups_fixed_size_sort_shuffle_pull_based_column08 column13
column14` | 256 MiB | — |
| `count_parquet_fixed_size` | 64 MiB | — |
| `cross_az_map_batches_autoscaling_iptable_failure_injection` | 1 GiB |
— |
| `distributed_training` | — | footer actors `20` |
| `flat_map` | 64 MiB | — |
| `iceberg_benchmark_overwrite` | 64 MiB | — |
| `iter_batches_pyarrow` | 64 MiB | — |
| `iter_torch_batches` | 64 MiB | — |
| `joins_{{dataset}}_{{join_type}} *(all 4 variants)*` | 1.25 GiB | — |
| `map` | 64 MiB | — |
| `map_batches_fixed_size_{{compute}}_{{format}}_{{repeat_map_batches}}
*(all 7 variants)*` | 1 GiB | scale-up threshold `0.6` |
| `map_groups_fixed_size_{{shuffle_strategy}}_{{columns}} *(all 6
variants)*` | 1.25 GiB | — |
| `mix` | — | footer actors `4` |
| `random_shuffle_fixed_size` | 64 MiB | — |
| `read_large_parquet_fixed_size` | 1 GiB | — |
| `read_parquet_fixed_size` | 64 MiB | — |
| `read_tfrecords` | 64 MiB | — |
| `streaming_split` | 64 MiB | footer batch `50`, result batch `50` |
| `to_tf` | 64 MiB | — |
| `tpch_q1_fixed_size_{{shuffle_strategy}} *(all 2 variants)*` | 192 MiB
| — |
| `training_ingest_benchmark` | 64 MiB | — |
| `wide_schema_pipeline_nested_structs` | 2 MiB | footer batch `1`,
footer actors `21`, io threads `5000` |
| `wide_schema_pipeline_objects` | 4.2 MiB | footer batch `1`, footer
actors `9`, io threads `5000` |
| `wide_schema_pipeline_primitives` | 256 KiB | footer batch `1`, footer
actors `27`, io threads `5000` |
| `wide_schema_pipeline_tensors` | 39 MiB | footer batch `1`, footer
actors `22`, io threads `5000` |
| `write_parquet` | 1.25 GiB | — |

**Three matrices are split**, because a matrix cannot vary
`byod.runtime_env` per value and their variants want different budgets:
`wide_schema_pipeline_{{data_type}}` into four entries, and one variant
each out of `iceberg_benchmark_{{mode}}` and `iter_batches_{{format}}`.
`aggregate_groups` keeps its matrix and carries the budget as a matrix
dimension with explicit adjustments. **Rendered test names are unchanged
— 121 before and after** — so release baselines still line up.

**Not carried over** from the original branch: 7 previously-pinned
entries no longer exist — the autoscaling variants removed in #65506,
plus `tpch_q20` and `tpch_q22`.

Any entry gaining its own `runtime_env` re-lists the four `DEFAULTS`
guards verbatim: `deep_update` overwrites lists rather than merging
them, so declaring one silently drops the OOM / dead-node / object-store
checks. (17 entries on master are already missing guards for this
reason; pre-existing, not touched here.)

`map_benchmark.py` also drops its `use_datasource_v2 = False` pin, which
existed because V2 was spilling.

> Budgets originally measured against the pre-decoupling design and
refined since. Packing moved between stages in #65596 but the packer and
its inputs did not, so bins should be unchanged — a release run against
this PR is what confirms that. The wide-schema tests are the first place
to look.

## Behavior change worth reviewing

**Read-task sizing no longer comes from `override_num_blocks` /
`read_op_min_num_blocks` for Parquet.** Bins are sized by
`RAY_DATA_PARQUET_BIN_PACKING_BYTES`, which is *also* not derived from
`DataContext.target_max_block_size`. That decoupling is deliberate —
read units are row-group-accurate rather than size-estimated — but it
means the two knobs users reach for first no longer affect Parquet read
parallelism. Deriving the budget from `target_max_block_size` is worth
considering as a follow-up; the per-test overrides above are the
evidence that a single global default does not fit every workload.

## Testing

```
$ python -m pytest -q python/ray/data/tests/datasource/test_parquet.py
286 passed, 6 skipped in 521.25s

$ python -m pytest -q python/ray/data/tests/datasource/test_read_parquet_v2.py
32 passed

$ python -m pytest -q python/ray/data/tests/unit/datasource_v2/ python/ray/data/_internal/datasource_v2/tests/
181 passed

$ python -m pytest -q python/ray/data/tests/test_predicate_pushdown.py \
                     python/ray/data/tests/test_execution_optimizer_limit_pushdown.py
78 passed
```

The 286-test parquet suite is the one that matters — it runs the full
read surface with the footer path as the default rather than behind a
flag. The release YAML is additionally checked for parse validity,
unresolved `{{...}}` in any pin, duplicate `byod:` keys, and
rendered-name stability.

## Stack

Final step of an 11-step split of #64985 (43 files / +3234 −719, not
reviewable as one unit).

- #65167 `[1]` · #65168 `[2]` · #65214 `[3]` · #65210 `[4]` · #65273
`[5]` · #65596 `[6]` · #65806 `[8]` · #65169 `[9]` — all merged
- `[7]` (count push-down fix) was absorbed into #65596
- `[10]` (release tuning) is folded into this PR, so a release run
exercises the flip and its tuning together
- **this PR** `[11/11]`

---
Not a duplicate. File-level overlap check: #63158 none; #65142 overlaps
`file_indexer.py` / `context.py`; #65406 / #65407 (arrow-rs reader A/B)
overlap broadly but are explicitly `[DO NOT MERGE]` benchmark branches
carrying the footer work out-of-tree.
AI assistance was used; every line reviewed by me and tests run locally.

---------

Signed-off-by: Goutam <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ay-project#65806)

## Why

Two independent throughput knobs for the Parquet read task, kept out of
the footer-indexer PR because each changes behavior on its own and needs
its own justification.

**One reader thread per fragment, instead of capping at 4.** The cap
existed because the blind `ParquetFileChunker` could put an unbounded
number of row groups — and therefore fragments — in a single read task,
so an uncapped thread pool was a real risk. Now that ray-project#65596 has landed,
read units are bin-packed to a byte budget, so the fragment count per
task is bounded by construction and the cap only serializes IO that
could overlap.

**Size Arrow's IO/CPU pools for the read task.** Arrow's defaults (~num
cores, 8 IO threads) throttle the concurrent column/range fetches a
Parquet scan issues against S3. That hurts most for row-group-scoped
fragments, which is exactly what the footer path now produces.

## Flow

No structural change — both are sizing knobs on the existing read path:

```
ReadFiles task
  ├─ pa.set_io_thread_count / set_cpu_count   ← new, at reader construction
  └─ _read_fragment_batches
       └─ num_workers = len(fragments)        ← was min(4, len(fragments))
```

The sequential path still applies when
`DataContext.execution_options.preserve_order` is set, unchanged.

## What changed

| File | Change |
| --- | --- |
| `readers/file_reader.py` | Drop `_DEFAULT_NUM_THREADS` /
`RAY_DATA_READ_FILES_NUM_THREADS`; `num_workers =
len(fragments_with_offsets)`. Also fixes the `_read_fragment_batches`
docstring, which still documented the removed env var. |
| `readers/parquet_file_reader.py` | `pa.set_io_thread_count()` /
`pa.set_cpu_count()` at reader construction, from
`RAY_DATA_PARQUET_READER_IO_THREAD_COUNT` /
`RAY_DATA_PARQUET_READER_CPU_COUNT` (default 128 each; `0` disables). |

**Two things worth a careful look:**

- This **removes** `RAY_DATA_READ_FILES_NUM_THREADS`. It is undocumented
and internal, but anyone setting it loses the knob.
- `pa.set_io_thread_count` / `set_cpu_count` mutate **process-global**
Arrow state from a constructor. That is deliberate — the read task is
the process — but it means a non-Parquet reader sharing the worker sees
the same pools.

## Stack

Step 8 of an 11-step split of ray-project#64985.

- ray-project#65167 `[1/11]` ✅ · ray-project#65168 `[2/11]` ✅ · ray-project#65214 `[3/11]` ✅ · ray-project#65210
`[4/11]` ✅ · ray-project#65273 `[5/11]` ✅
- ray-project#65596 `[6/11]` ✅ — footer indexer behind the flag, which also
absorbed step 7's `count()` fix and moved bin packing into a
`FilePartitioner`
- **this PR** `[8/11]` — unblocked by ray-project#65596: the thread cap can only
come off once bins are size-bounded
- ray-project#65169 `[9/11]` pin the footer actor pool to 1 in tests (open,
independent)

Remaining after this: release-test tuning, then flipping the default and
deleting the old chunker.

---------

Signed-off-by: Goutam <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ect#65821)

## Why

The last step of the split of ray-project#64985: flip Parquet V2 to the footer read
path, delete the blind one, and tune the release tests so this can be
validated by a real release run.

Everything it depends on has landed — footer types and the bin packer
(ray-project#65210), the `FooterReader` actor pool (ray-project#65273), the indexer plus
`count()` fix and packer-as-partitioner (ray-project#65596), reader IO tuning
(ray-project#65806), and test env pinning (ray-project#65169). The path has been reachable
behind `RAY_DATA_PARQUET_ENABLE_FOOTER_INDEXER` since ray-project#65596; this makes
it the only path.

## Flow

```mermaid
flowchart LR
  RP[read_parquet] --> FF["FooterFileIndexer<br/>+ OnlineBinPacker"]
  RP -.->|deleted| PC["ParquetFileChunker<br/>size-estimated chunks<br/>+ parquet_chunker_target_chunk_size"]
  style PC stroke-dasharray: 4 4
```

## What changed

**The flip** — `RAY_DATA_PARQUET_ENABLE_FOOTER_INDEXER` is gone from
both call sites. `_get_file_indexer()` always returns
`FooterFileIndexer`; `get_file_partitioner()` always returns
`OnlineBinPacker`.

**The deletions** — `ParquetFileChunker`, `ParquetFileChunkMetadata`,
`_calculate_row_group_range`, `_fragments_from_chunk_metadata`, and the
tests covering only that path.

**The config it left behind** —
`DataContext.parquet_chunker_target_chunk_size` and
`DEFAULT_PARQUET_CHUNKER_TARGET_CHUNK_SIZE` were read *only* by
`ParquetFileChunker.__init__`, so they would otherwise stay declared and
documented while doing nothing. Verified dead by grep across `.py` /
`.yaml` / `.rst` / `.md`.

**Reader pool defaults** — `RAY_DATA_PARQUET_READER_IO_THREAD_COUNT`
128, `RAY_DATA_PARQUET_READER_CPU_COUNT` 32.

## Release tests tuned

Budgets are per-test overrides of `RAY_DATA_PARQUET_BIN_PACKING_BYTES`
(uncompressed bytes of row-group data per read task; default 128 MiB).
The shape of the tuning: reads over few large groups want **large**
bins, because small bins shatter the read into short tasks the executor
cannot dispatch fast enough and the cluster idles; shuffle-bound reads
over many groups want **small** bins.

Rows whose variants all share the same tuning are collapsed and marked.

| release test | bin budget | other tuning |
| --- | --- | --- |
| `aggregate_groups_fixed_size_hash_shuffle_column02 column14` | 32 MiB
| — |
| `aggregate_groups_fixed_size_hash_shuffle_column08 column13 column14`
| 128 MiB | — |
| `aggregate_groups_fixed_size_shuffle_v2_column02 column14` | 64 MiB |
— |
| `aggregate_groups_fixed_size_shuffle_v2_column08 column13 column14` |
512 MiB | — |
| `aggregate_groups_fixed_size_sort_shuffle_pull_based_column02
column14` | 32 MiB | — |
| `aggregate_groups_fixed_size_sort_shuffle_pull_based_column08 column13
column14` | 256 MiB | — |
| `count_parquet_fixed_size` | 64 MiB | — |
| `cross_az_map_batches_autoscaling_iptable_failure_injection` | 1 GiB |
— |
| `distributed_training` | — | footer actors `20` |
| `flat_map` | 64 MiB | — |
| `iceberg_benchmark_overwrite` | 64 MiB | — |
| `iter_batches_pyarrow` | 64 MiB | — |
| `iter_torch_batches` | 64 MiB | — |
| `joins_{{dataset}}_{{join_type}} *(all 4 variants)*` | 1.25 GiB | — |
| `map` | 64 MiB | — |
| `map_batches_fixed_size_{{compute}}_{{format}}_{{repeat_map_batches}}
*(all 7 variants)*` | 1 GiB | scale-up threshold `0.6` |
| `map_groups_fixed_size_{{shuffle_strategy}}_{{columns}} *(all 6
variants)*` | 1.25 GiB | — |
| `mix` | — | footer actors `4` |
| `random_shuffle_fixed_size` | 64 MiB | — |
| `read_large_parquet_fixed_size` | 1 GiB | — |
| `read_parquet_fixed_size` | 64 MiB | — |
| `read_tfrecords` | 64 MiB | — |
| `streaming_split` | 64 MiB | footer batch `50`, result batch `50` |
| `to_tf` | 64 MiB | — |
| `tpch_q1_fixed_size_{{shuffle_strategy}} *(all 2 variants)*` | 192 MiB
| — |
| `training_ingest_benchmark` | 64 MiB | — |
| `wide_schema_pipeline_nested_structs` | 2 MiB | footer batch `1`,
footer actors `21`, io threads `5000` |
| `wide_schema_pipeline_objects` | 4.2 MiB | footer batch `1`, footer
actors `9`, io threads `5000` |
| `wide_schema_pipeline_primitives` | 256 KiB | footer batch `1`, footer
actors `27`, io threads `5000` |
| `wide_schema_pipeline_tensors` | 39 MiB | footer batch `1`, footer
actors `22`, io threads `5000` |
| `write_parquet` | 1.25 GiB | — |

**Three matrices are split**, because a matrix cannot vary
`byod.runtime_env` per value and their variants want different budgets:
`wide_schema_pipeline_{{data_type}}` into four entries, and one variant
each out of `iceberg_benchmark_{{mode}}` and `iter_batches_{{format}}`.
`aggregate_groups` keeps its matrix and carries the budget as a matrix
dimension with explicit adjustments. **Rendered test names are unchanged
— 121 before and after** — so release baselines still line up.

**Not carried over** from the original branch: 7 previously-pinned
entries no longer exist — the autoscaling variants removed in ray-project#65506,
plus `tpch_q20` and `tpch_q22`.

Any entry gaining its own `runtime_env` re-lists the four `DEFAULTS`
guards verbatim: `deep_update` overwrites lists rather than merging
them, so declaring one silently drops the OOM / dead-node / object-store
checks. (17 entries on master are already missing guards for this
reason; pre-existing, not touched here.)

`map_benchmark.py` also drops its `use_datasource_v2 = False` pin, which
existed because V2 was spilling.

> Budgets originally measured against the pre-decoupling design and
refined since. Packing moved between stages in ray-project#65596 but the packer and
its inputs did not, so bins should be unchanged — a release run against
this PR is what confirms that. The wide-schema tests are the first place
to look.

## Behavior change worth reviewing

**Read-task sizing no longer comes from `override_num_blocks` /
`read_op_min_num_blocks` for Parquet.** Bins are sized by
`RAY_DATA_PARQUET_BIN_PACKING_BYTES`, which is *also* not derived from
`DataContext.target_max_block_size`. That decoupling is deliberate —
read units are row-group-accurate rather than size-estimated — but it
means the two knobs users reach for first no longer affect Parquet read
parallelism. Deriving the budget from `target_max_block_size` is worth
considering as a follow-up; the per-test overrides above are the
evidence that a single global default does not fit every workload.

## Testing

```
$ python -m pytest -q python/ray/data/tests/datasource/test_parquet.py
286 passed, 6 skipped in 521.25s

$ python -m pytest -q python/ray/data/tests/datasource/test_read_parquet_v2.py
32 passed

$ python -m pytest -q python/ray/data/tests/unit/datasource_v2/ python/ray/data/_internal/datasource_v2/tests/
181 passed

$ python -m pytest -q python/ray/data/tests/test_predicate_pushdown.py \
                     python/ray/data/tests/test_execution_optimizer_limit_pushdown.py
78 passed
```

The 286-test parquet suite is the one that matters — it runs the full
read surface with the footer path as the default rather than behind a
flag. The release YAML is additionally checked for parse validity,
unresolved `{{...}}` in any pin, duplicate `byod:` keys, and
rendered-name stability.

## Stack

Final step of an 11-step split of ray-project#64985 (43 files / +3234 −719, not
reviewable as one unit).

- ray-project#65167 `[1]` · ray-project#65168 `[2]` · ray-project#65214 `[3]` · ray-project#65210 `[4]` · ray-project#65273
`[5]` · ray-project#65596 `[6]` · ray-project#65806 `[8]` · ray-project#65169 `[9]` — all merged
- `[7]` (count push-down fix) was absorbed into ray-project#65596
- `[10]` (release tuning) is folded into this PR, so a release run
exercises the flip and its tuning together
- **this PR** `[11/11]`

---
Not a duplicate. File-level overlap check: ray-project#63158 none; ray-project#65142 overlaps
`file_indexer.py` / `context.py`; ray-project#65406 / ray-project#65407 (arrow-rs reader A/B)
overlap broadly but are explicitly `[DO NOT MERGE]` benchmark branches
carrying the footer work out-of-tree.
AI assistance was used; every line reviewed by me and tests run locally.

---------

Signed-off-by: Goutam <[email protected]>
goutamvenkat-anyscale pushed a commit that referenced this pull request Nov 24, 2026
The shared DataSource V2 `FileReader` now limits each parallel read task
to 64 Python fragment workers by default. Parquet can pack many small
files into one task by byte size, so a 128-fragment task previously
started 128 scan threads.

```mermaid
flowchart LR
    subgraph Before["Before · IO / FileReader"]
        B["128 fragments in one task"] --> BW["128 scan workers"]
    end
    subgraph After["After · IO / FileReader"]
        A["128 fragments in one task"] --> AW["64 scan workers by default"]
    end
    classDef removed fill:#ffcdd2,color:#222
    classDef added fill:#c8e6c9,color:#222
    class BW removed
    class AW added
```

To override the default, set `RAY_DATA_FILE_READER_MAX_FRAGMENT_WORKERS`
in the worker environment before importing Ray Data. The reader uses
`min(fragment_count, configured_limit)`. A limit of 1 or less selects
the sequential path, as does `execution_options.preserve_order=True`.
Use the same setting on all workers so retries can reproduce the batch
sequence.

Fixes #68342. This is the only open PR I found addressing that issue.
#65806 removed an earlier four-thread limit to improve remote I/O
overlap.

**Subsystems** · IO (shared V2 file reader) and API (Parquet and ORC
read documentation).

## Testing

```bash
python -m pytest -q python/ray/data/tests/test_context.py \
  python/ray/data/tests/unit/datasource_v2/{test_parquet_datasource_v2,test_hive_direct,test_parquet_size_statistics,test_parquet_row_group_coalescing,test_parquet_decoded_size,test_orc_file_reader,test_orc_datasource_v2}.py
```

All 704 tests passed locally at `f0249d41c5` using the branch’s Ray Data
code and Ray Core nightly `eb50407602`. All applicable pre-commit hooks
passed.

The regression test reads three Parquet files in each case. A cap of 2
uses two fragment workers, a cap of 4 uses three workers, and a cap of 0
reads sequentially. Each case verifies that all three row IDs appear
exactly once.

---------

Signed-off-by: zzchun <[email protected]>
Signed-off-by: will <[email protected]>
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.

2 participants