Skip to content

[Data] Fix excessive scan threads in V2 file reads - #68344

Merged
goutamvenkat-anyscale merged 4 commits into
ray-project:masterfrom
zzchun:feat/parquet-v2-fragment-worker-cap
Nov 24, 2026
Merged

goutamvenkat-anyscale merged 4 commits into
ray-project:masterfrom
zzchun:feat/parquet-v2-fragment-worker-cap

Conversation

@zzchun

@zzchun zzchun commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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.

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
Loading

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

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.

@zzchun zzchun changed the title [Data] Allow capping Parquet V2 fragment workers [Data] Fix excessive Parquet V2 scan threads with an opt-in cap Nov 19, 2026
Allow a DataContext setting to limit the Python fragment scan workers per Parquet V2 read task. Store the cap on the scanner so a retried task uses the same worker count and batch order.

Signed-off-by: zzchun <[email protected]>
@zzchun
zzchun force-pushed the feat/parquet-v2-fragment-worker-cap branch from 02a3fef to a87e1fb Compare November 19, 2026 12:47
@zzchun
zzchun marked this pull request as ready for review November 19, 2026 12:53
@zzchun
zzchun requested review from a team as code owners November 19, 2026 12:53

@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 the parquet_max_fragment_workers configuration to limit the number of concurrent fragment scan workers per Parquet V2 read task. This limit is exposed via DataContext and the RAY_DATA_PARQUET_MAX_FRAGMENT_WORKERS environment variable, with backward compatibility handled for older serialized datasets. The review feedback suggests strengthening the validation of max_fragment_workers in FileReader to strictly require a positive integer, preventing potential type mismatches with floats or booleans.

@ray-gardener ray-gardener Bot added data Ray Data-related issues community-contribution Contributed by the community labels Nov 19, 2026
@zzchun zzchun changed the title [Data] Fix excessive Parquet V2 scan threads with an opt-in cap [Data] Cap V2 file reads at 64 fragment workers per task by default Nov 20, 2026
@zzchun zzchun changed the title [Data] Cap V2 file reads at 64 fragment workers per task by default [Data] Fix excessive scan threads in V2 file reads Nov 20, 2026
Comment thread python/ray/data/read_api.py Resolved
@AarryaSaraf AarryaSaraf added the go add ONLY when ready to merge, run all tests label Nov 23, 2026

zzchun commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Hi @goutamvenkat-anyscale, would you have a chance to take a look at this PR when you have a moment? Given your work on Parquet read concurrency in #65806, I’d really appreciate your thoughts on the default cap of 64 fragment workers per V2 read task.

If it looks good to you, I’d appreciate your help getting it merged. Thanks for your time!

@goutamvenkat-anyscale
goutamvenkat-anyscale merged commit a694afe into ray-project:master Nov 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community 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.

[Data] Parquet V2 starts one scan thread per fragment when packing small files

3 participants