Skip to content

[Data] Size the schema pin and the columns Ray adds in the Parquet decoded-size estimate [3/6] - #67838

Merged
goutamvenkat-anyscale merged 84 commits into
masterfrom
aarrya/decoded-size-3-ray-read
Nov 13, 2026
Merged

goutamvenkat-anyscale merged 84 commits into
masterfrom
aarrya/decoded-size-3-ray-read

Conversation

@AarryaSaraf

@AarryaSaraf AarryaSaraf commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follows #67837, which is merged.

Extends the estimator with what a Ray read does beyond PyArrow's decode, and splits it from one file into the package formats/parquet/decoded_size/ (arrow_layout, schema_walk, schema_pin, footer_counts, added_columns, estimate; __init__ re-exports the public names). The split is its own commit and only moves code. Nothing calls the estimator yet, so behavior doesn't change.

A Ray read returns different arrays than the file stores: when the dataset schema is pinned, Ray casts every batch to it, and Ray appends columns such as path. Rather than size the cast on its own, the estimate walks the schema the read returns, so #67837's per-array sizing applies unchanged.

flowchart TD
    A["File's Arrow schema"] -->|"no pinned schema"| W["Schema walked"]
    D["Pinned dataset schema"] -->|"columns the cast maps leaf for leaf"| W
    D -->|"columns whose shape the cast changes"| U["Not modelled"]
    K["binary_type, list_type"] -->|"the whole file"| U
    C["dictionary_columns"] -->|"the BYTE_ARRAY columns it names"| U
    W -->|"#67837's per-array sizing"| L["Leaf bytes"]
    R["Columns Ray adds"] -->|"added_bytes, per row"| T["Row group estimate"]
    L -->|"summed"| T
Loading
  • build_leaf_profiles gains pinned_schema and format_kwargs. pinned_schema is the schema the reader casts every batch to (FileReader._file_dataset_schema), not the dataset schema.
    • A pinned column whose leaves the cast keeps one for one is walked at its pinned type (_pinned_walk, pinned_type): an int32 column pinned to int64 counts 8 bytes a value.
    • Whether a column without nulls keeps its validity bitmap depends on the cast (_cast_keeps_bitmap, measured on PyArrow 23 to 26): int32 pinned to date32 keeps it, int32 pinned to int64 drops it.
    • A cast that changes a column's shape (a struct gaining a field, a nested field made nullable, numbers cast to text) leaves that column's leaves unmodelled, for the caller to charge.
    • A read with binary_type or list_type isn't modelled. dictionary_columns leaves only the BYTE_ARRAY columns it names unmodelled. The reader drops these options when it casts to the schema ([Data] Pack Parquet read tasks by estimated decoded size in DSv2 [5/6] #67840).
  • estimate_row_group takes a Read, the bytes per row and per row group of the columns Ray appends (added_bytes, estimate_added_columns): path, the file's partition values as the reader parses them ({"year": "2024"} gives year 4 bytes a row), and a dataset column the file lacks or holds as a null-typed column, which the cast fills with nulls.

Accuracy, measured before the review changes and not re-run since: a bench wrote 10,000 files from 100 fixed random seeds, drawing the writer (PyArrow, Polars or arrow-rs), column types, encodings, compression, row-group sizes, read options and pinned schemas at random, and measured the bytes PyArrow holds for each row group a Ray read decodes. The bench over-weights what the estimate leaves unmodelled (26% of reads use a type option, 9% dictionary_columns, 13% of the files come from Polars, which writes no SizeStatistics, and the bench strips parts of them at random, from 58% of the row groups), so it models 30,160 of 148,039 row groups (20%).

Estimate ÷ PyArrow's bytes Today: uncompressed bytes, all row groups This estimate, row groups it models
< 0.95 76.1% 0
0.95–1.1 11.5% 99.2%
median / p90 / p99 0.68× / 1.19× / 4.94× 1.00× / 1.00× / 1.06×

Tests: tests/unit/datasource_v2/test_parquet_decoded_size.py, 79 passed on Python 3.10 with PyArrow 23.0.0 and 25.0.1 and on Python 3.12 with PyArrow 26.0.1. New cases: eleven pinned casts, each with and without nulls, match what a scan under the pinned schema holds; binary_type leaves the file unmodelled and dictionary_columns only the columns it names; a stored dictionary column is unmodelled; a text pin over a non-text column is unmodelled; and the added columns (path, a string, a dictionary and a null partition value, a null-filled column) are within 5% of what PyArrow holds.

Signed-off-by: Aarrya [email protected]

🤖 Generated with Claude Code

AarryaSaraf and others added 10 commits October 30, 2026 12:13
…w doesn't expose

Co-authored-by: Goutam <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
…ader dataclasses

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
… per leaf

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
…le docstring

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

@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 enhances the Parquet decoded size estimation in Ray Data to account for schema pinning, read options, and added columns. Feedback on the changes highlights several critical issues: a potential 'TypeError' when passing 'Field' objects instead of 'DataType's to 'pa.map_', a potential 'None' value issue when reading statistics, an unhandled 'AttributeError' when accessing 'bit_width', and a cross-platform path separator issue on Windows when parsing Hive partitions.

Comment on lines +861 to +865
if pa.types.is_map(arrow_type):
key, item = arrow_type.key_field, arrow_type.item_field
return pa.map_(
key.with_type(retype(key.type)), item.with_type(retype(item.type))
)

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

In PyArrow, pa.map_ expects DataType objects for its key_type and item_type arguments. Passing Field objects (returned by with_type) will raise a TypeError at runtime. We should pass the retyped DataTypes directly instead.

Suggested change
if pa.types.is_map(arrow_type):
key, item = arrow_type.key_field, arrow_type.item_field
return pa.map_(
key.with_type(retype(key.type)), item.with_type(retype(item.type))
)
if pa.types.is_map(arrow_type):
key, item = arrow_type.key_field, arrow_type.item_field
return pa.map_(
retype(key.type), retype(item.type)
)

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.

That map-rebuilding code is gone; the pinned walk takes types straight from the dataset schema.

Comment on lines +1231 to +1232
for value in (statistics.min, statistics.max):
if decimal:

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.

medium

If statistics.min or statistics.max is None (which can happen in some edge cases or older PyArrow versions even if has_min_max is True), str(value) will evaluate to "None" (length 4), which is incorrect for integer/decimal types. We should explicitly check if value is None and return None to safely fall back to the type's default text bytes estimation.

Suggested change
for value in (statistics.min, statistics.max):
if decimal:
for value in (statistics.min, statistics.max):
if value is None:
return None
if decimal:

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.

Gone: numbers cast to text are now left unmodelled instead of sized from min/max statistics.

)
try:
return 1 + math.ceil(arrow_type.bit_width / 8)
except ValueError:

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.

medium

Accessing arrow_type.bit_width can raise AttributeError instead of ValueError if the attribute is not defined on the type object (depending on the PyArrow version or custom types). We should catch both ValueError and AttributeError to ensure robust fallback.

Suggested change
except ValueError:
except (ValueError, AttributeError):

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.

Every pa.DataType has bit_width; it raises ValueError for a type without a fixed width, which is what's caught.

``year`` 4 bytes a row.
"""
path_bytes = len(path.encode())
partitions = dict(part.split("=", 1) for part in path.split("/") if "=" in part)

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.

medium

On Windows, file paths use \\ as the directory separator instead of /. To ensure that Hive partition values are correctly extracted on all platforms, we should normalize the path separators by replacing \\ with / before splitting. This also prevents potential test failures on Windows where partition values like year=2024 would otherwise fail to be parsed.

Suggested change
partitions = dict(part.split("=", 1) for part in path.split("/") if "=" in part)
partitions = dict(part.split("=", 1) for part in path.replace("\\", "/").split("/") if "=" in part)

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.

This splits on / like Ray's own Hive partition parser in partitioning.py, so both agree on the values Ray appends.

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

…binaries image so //:ray_pkg_zip can build it

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
@AarryaSaraf
AarryaSaraf force-pushed the aarrya/decoded-size-3-ray-read branch from 425abd0 to 1a12e26 Compare November 4, 2026 22:36

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

…ed Parquet walk, which a signed cast could turn negative

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
@AarryaSaraf
AarryaSaraf force-pushed the aarrya/decoded-size-3-ray-read branch from 1a12e26 to 5b77eca Compare November 4, 2026 23:28
@ray-gardener ray-gardener Bot added the data Ray Data-related issues label Nov 5, 2026
…n walk and reading dictionary page headers in the compiled reader

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
@AarryaSaraf
AarryaSaraf force-pushed the aarrya/decoded-size-3-ray-read branch from 5b77eca to 1668d2a Compare November 5, 2026 02:06
…ompact reader builds on Windows

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
@AarryaSaraf
AarryaSaraf force-pushed the aarrya/decoded-size-3-ray-read branch from 1668d2a to 688ddcf Compare November 5, 2026 03:46
AarryaSaraf and others added 8 commits November 9, 2026 14:43
…ize tests

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
…e, and test it from one table

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
…out changing an estimate

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
…eaf's kind from its profile

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
…odelled instead of failing the file or guessing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
…ounding them

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
…d be bounds

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
@AarryaSaraf AarryaSaraf added the go add ONLY when ready to merge, run all tests label Nov 9, 2026
…r' into decoded-size-3-ray-read

Signed-off-by: Aarrya <[email protected]>

# Conflicts:
#	python/ray/data/_internal/datasource_v2/formats/parquet/parquet_decoded_size.py
#	python/ray/data/tests/unit/datasource_v2/test_parquet_decoded_size.py

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

@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 440b177. Configure here.

AarryaSaraf and others added 2 commits November 10, 2026 17:46
…as no dictionary page and no SizeStatistics

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
Base automatically changed from aarrya/decoded-size-2-estimator to master November 11, 2026 08:59
goutamvenkat-anyscale pushed a commit that referenced this pull request Nov 11, 2026
…oter [2/6] (#67837)

## Description

Stacked on #67836.

Adds `formats/parquet/parquet_decoded_size.py`, which estimates the
bytes a Parquet row group takes once PyArrow decodes it to Arrow, from
the footer alone. Ray sizes a row group today by its uncompressed bytes,
which are still dictionary- and RLE-encoded. Nothing calls this module
yet, so behavior doesn't change.

The idea: a decoded Arrow column is a few buffers (validity bitmap,
offsets, values), and each buffer's size follows from three counts: how
many elements the array has, how many are null, and, for strings, how
many value bytes there are. The footer records those counts exactly when
the writer wrote `SizeStatistics`. A leaf whose counts it doesn't record
exactly isn't estimated: the caller charges it by its uncompressed bytes
instead (#67840).

How it works:
1. Once per file, `build_leaf_profiles` walks the Arrow schema into one
chain of arrays per Parquet leaf: its structs and lists, then the leaf.
2. Per row group, `LeafChunk` reads each array's length and nulls from
the leaf's level histograms, or, for a top-level leaf, from the footer's
null count.
3. Each array is sized as bitmap plus offsets plus values. A string
leaf's value bytes come from `SizeStatistics`.
4. `estimate_row_group` sums over the leaves read, counting a struct or
list that several leaves share once.

```mermaid
flowchart TD
    S["Arrow schema"] -->|"walked once per file"| P["Each leaf's chain of arrays"]
    F["Row group footer"] -->|"level histograms, or a top-level leaf's null count"| C["Each array's length and nulls"]
    P -->|"the arrays to count"| C
    C -->|"bitmap, offsets, fixed-width values"| A["Array bytes"]
    F -->|"SizeStatistics"| V["String value bytes"]
    A -->|"shared arrays counted once"| T["Row group estimate"]
    V -->|"added to the string leaf"| T
    F -->|"counts it doesn't record exactly"| U["No estimate: the caller charges the leaf"]
```

This is what the dataflow looks like

```mermaid
flowchart TD
    subgraph file ["Once per file"]
        blp["build_leaf_profiles"] --> tas["parquet_schema.to_arrow_schema"]
        blp --> walk["_walk"]
        walk --> visit["visit → _visit_struct / _visit_list / _visit_leaf, recursive"]
        visit --> node["_node"]
        visit --> layout["_leaf_layout"]
        layout --> dst["detect_string_type / _offset_width"]
        layout --> zc["_is_zero_copy_type"]
        visit --> rep["_is_repeated / _is_list"]
        blp --> match["_matches"]
    end

    subgraph rg ["Once per row group"]
        lc["leaf_chunks"] --> chunk["LeafChunk"]
        chunk --> dba["detect_delta_byte_array"]
        chunk --> agree["_histograms_agree"]
        lc --> modelled["modelled"]
        modelled --> known["levels_known"]
    end

    subgraph sum ["The byte sum"]
        erg["estimate_row_group"] --> anc["estimate_ancestors"]
        erg --> leaf["estimate_leaf"]
        leaf --> fw["estimate_fixed_width"]
        leaf --> sb["estimate_string_bytes"]
        sb --> st["estimate_string_type"]
        anc --> ab["_array_bytes"]
        fw --> ab
        st --> bm["bitmap / array_length"]
        ab --> bm
        bm --> hist["_opened / _below / _nulls"]
        bm --> bits["_bytes_for_bits"]
    end

    match --> lc
    modelled --> erg
```

- With `SizeStatistics` (read by #67836) every count is exact.
- Without them, as in files from Spark 3.5 or PyArrow 17, only leaves
whose counts the footer still pins down are sized: a non-string leaf at
the top level, whose nulls are the footer's null count, or one that
can't be null at any level. Every other leaf, including every string and
every list element, gets no chunk from `leaf_chunks`, so the caller
charges it.
- Also left to the caller: views, Arrow dictionary types and unions get
no profile, and a string leaf whose `SizeStatistics` bytes can't be
trusted (only parquet-java and arrow-rs are trusted to count
`DELTA_BYTE_ARRAY` values in full; Arrow C++ undercounts them) has no
bytes to size. A schema PyArrow can't convert, or the walk can't handle,
gives `None` for the whole file.

Accuracy on a 10,000-file bench, with #67838's handling of the read, is
in #67838.

Tests: `tests/unit/datasource_v2/test_parquet_decoded_size.py`, 48
passed. They compare the estimate with the buffers a real PyArrow scan
allocates (`get_total_buffer_size`), not with a hand-computed formula.
Without `SizeStatistics`, a string and a list column fall back while an
`int64` beside them stays exact.

Signed-off-by: Aarrya <[email protected]>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Aarrya <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
AarryaSaraf and others added 2 commits November 12, 2026 10:59
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
…mate's pinned walk

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Aarrya <[email protected]>
if pa.types.is_null(field.type)
else pinned_type(field=field, pinned_schema=pinned_schema)
)
pinned = field if arrow_type is None else field.with_type(arrow_type)

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.

Under the pin, keeps_bitmap now comes from _is_zero_copy_type(<pinned type>) plus the stored physical-type check at L367. But whether the cast output keeps the all-valid bitmap depends on the cast, not the target type: a computed cast like int32→int64 builds a new array without one, while a reinterpretation like int32→date32 keeps the decoded one.

Measured with PyArrow 21 on a nullable column with no nulls, 5,000 rows, scanned under a pinned schema:

stored → pinned held estimate
int32 → date32 20,625 20,000 (low)
int64 → duration 40,625 40,000 (low)
int32 → int64 40,000 40,625
float32 → float64 40,000 40,625
uint32 → int64 40,000 40,625

The low rows are the ones that matter. This probably needs to key on the (stored, pinned) pair rather than the pinned type alone. (Anchoring here because L367 is outside the diff.)

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.

Confirmed and fixed. The bitmap now depends on the stored and pinned types together (_cast_keeps_bitmap): int32/int64 cast to a temporal type of the same width, and a timestamp cast to a timestamp or int64, keep it; every other cast drops it. Your five rows are exact and in test_pinned_cast_is_exact.

the path and the Hive values cut from it hold text: ``year=2024/`` gives
``year`` 4 bytes a row."""
path_bytes = len(path.encode())
partitions = dict(part.split("=", 1) for part in path.split("/") if "=" in part)

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.

This splits k=v segments out of the raw path instead of using the partition parsing the reader does (PathPartitionParser), so it can disagree with what the read actually adds:

  • Partitioning("dir", field_names=[...]) paths have no =, so those columns get 0 text bytes and are charged ~4 B a row instead of 4 + the value's length. This one is low.
  • __HIVE_DEFAULT_PARTITION__ is read as null but charged 26 B a row.
  • URL-encoded values (city=S%C3%A3o%20Paulo) are charged at their encoded length.
  • base_dir isn't stripped, so a k=v segment above the dataset root gets picked up.

Could the caller pass in the parsed partition values instead?

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.

Agreed. added_bytes now takes partition_values, as the reader's parser produces them, and no longer parses the path. Its only caller is in #67840, which will pass them.

def _cast_maps(walk: _SchemaWalk, columns: Sequence[ColumnSchema]) -> bool:
"""Whether a column's leaves follow its pinned walk one for one."""
return len(walk.leaves) == len(columns) and all(
_matches(leaf=chain[-1], rep=rep, column=column)

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.

_matches accepts a binary leaf whenever the stored column is BYTE_ARRAY, so a decimal stored as BYTE_ARRAY (parquet-mr writes decimal(18,2) this way) and pinned to string counts as mapped. Its string bytes then come from SizeStatistics or the PLAIN bound of the raw two's-complement bytes (5–8 B a value), while the cast produces decimal text like 1234567890.12 (13 B). That's about 2× low.

The _pinned_walk docstring says numbers cast to text are left unmodelled; this case slips through. Checking that the stored column is itself text before accepting a text pin would close it.

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.

Fixed. A text pin is now accepted only when the stored leaf is itself text (_cast_maps), so a BYTE_ARRAY decimal pinned to string is left unmodelled like any other number cast to text. PyArrow can't write a BYTE_ARRAY decimal, so test_pinned_text_needs_stored_text drives _pinned_walk with a decimal Arrow type over a BYTE_ARRAY column.

for field in arrow_schema:
end = start + len(_walk(pa.schema([field])).leaves)
leaves = range(start, end)
# An all-null column keeps its type: its nulls count as an added column.

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.

A null-typed file column pinned to, say, string comes out of the cast as a full typed array of nulls (bitmap + offsets, ~20 KB per 5,000 rows), but it's sized at 0 here. The comment says its nulls count as an added column, but added_bytes and the comment at L744 only describe dataset columns the file lacks, so a caller following those docs will miss it.

Either size it here, or have added_bytes' docstring say explicitly that null-typed file columns under a pin belong in added.

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.

Took the second option. added_bytes' docstring and the comment above estimate_added_columns now say added holds every dataset column the pin fills with nulls, whether the file lacks it or holds it as a null-typed column. #67840's caller already collects both.

"""
format_kwargs = format_kwargs or {}
# Rare reads: the reader drops these options when it casts to the schema.
if format_kwargs.get("dictionary_columns") or detect_binary_or_list_type(

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.

The comment says the reader drops these options when it casts to the schema, so under a pin they don't change the output, but this returns None for the whole file either way. With read_dictionary plus a dataset schema, every file goes unmodelled and the caller (#67840) falls back to _UNMODELLED_RATIO * uncompressed, the approach the PR description's table shows under 0.95× in 76% of row groups.

It also fires when dictionary_columns names a column this file doesn't have. Suggest bailing only when pinned_schema is None, and only for columns present in this file.

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.

Half done. dictionary_columns now leaves only the BYTE_ARRAY columns it names unmodelled, so a column this file lacks changes nothing and the rest is sized. I didn't make it depend on the pin: with today's reader a pinned scan with dictionary_columns=["s"] holds 71,254 B against 70,629 B for a plain decode (the cast back adds a bitmap). In #67840 the reader drops these options when it casts and passes the stripped kwargs here, so nothing falls back under a pin.

for leaf in leaves:
size += estimate_ancestors(leaf=leaf, counted=counted)
size += estimate_leaf(leaf)
if detect_added_columns(read):

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: estimate_added_columns already returns 0 for Read(), so the detect_added_columns guard is redundant. Relatedly, added_bytes returns a bare tuple that every caller (the test here, and #67840) repacks into Read(added_row_bytes=..., added_row_group_bytes=...). Returning a Read directly would drop that glue.

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.

Both done. The guard and detect_added_columns are gone, and added_bytes returns a Read.

_ADDED_ROW_GROUP_BYTES = 9


def added_bytes(added: Sequence[pa.Field], path: str) -> tuple[float, int]:

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.

Not being used?

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.

Only by the test in this PR. Its caller is the footer reader in #67840 (FooterReader._added_bytes), which works out per file which columns get added.

arrow_type=child_type, text_bytes=child_text, path_bytes=path_bytes
)

row, once = 1 / 8, _ADDED_ROW_GROUP_BYTES

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.

What does this 1 bit represent?

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.

The validity bit: one bit per row in the array's null bitmap. Added a comment, and the docstring now lists the fixed charges.

@@ -10,7 +10,8 @@

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.

Would it make sense to split this file as:
It can be a follow up PR


Proposed layout: a formats/parquet/decoded_size/{package}. Line counts are approximate.

Module: arrow_layout.py
What moves there: Array kinds, _leaf_layout, _is_list, _is_repeated, _is_zero_copy_type,
  detect_string_type, _offset_width, _is_view, _is_text, _bytes_for_bits
Lines: ~100
Imports: pyarrow only
────────────────────────────────────────
Module: schema_walk.py
What moves there: _ArrowNode, LeafProfile, _Position, _SchemaWalk, _walk, _matches
Lines: ~230
Imports: arrow_layout
────────────────────────────────────────
Module: schema_pin.py (this PR)
What moves there: pinned_type, _pinned_walk, _struct_names, _cast_maps
Lines: ~75
Imports: schema_walk, arrow_layout
────────────────────────────────────────
Module: footer_counts.py
What moves there: LeafChunk, leaf_chunks, _PLAIN_STRING_ENCODINGS, detect_delta_byte_array
Lines: ~190
Imports: schema_walk, arrow_layout, parquet_size_statistics
────────────────────────────────────────
Module: added_columns.py (this PR)
What moves there: Read, detect_added_columns, estimate_added_columns, added_bytes,
  _added_array_bytes
Lines: ~95
Imports: arrow_layout
────────────────────────────────────────
Module: estimate.py
What moves there: build_leaf_profiles, detect_binary_or_list_type, estimate_row_group,
  estimate_leaf, estimate_ancestors, estimate_fixed_width, _array_bytes, estimate_string_*
Lines: ~170
Imports: all of the above
────────────────────────────────────────
Module: __init__.py
What moves there: Re-exports the public API
Lines: ~20
Imports:

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.

Done here, as its own commit with your layout: formats/parquet/decoded_size/ with arrow_layout, schema_walk, schema_pin, footer_counts, added_columns and estimate, and the public API re-exported from __init__. That commit only moves code, so the review fixes are easier to read in the commit before it.

if field.name == "path":
text_bytes = path_bytes
else:
text_bytes = len(partitions.get(field.name, "").encode())

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.

Where these constants come from isn't obvious from the code. Suggest documenting them in the docstring:

Suggested change
text_bytes = len(partitions.get(field.name, "").encode())
"""Bytes per element of an added array and its children, and once per row group.
Widths follow the Arrow columnar format. Besides the table, every array but a
null-type one is charged a validity bit a row and ``_ADDED_ROW_GROUP_BYTES``
once: the bitmap's last byte (1) and the offset past its last element (at
most 8). A list's or map's child is charged its once-bytes only, since the
cast fills the column with nulls and leaves the child empty.
======================== ================================ ====================
Type Per row Once
======================== ================================ ====================
null 0, no buffers 0
fixed width, bool ``bit_width / 8``
string, binary offset (4, ``large_``: 8) + text
string_view, binary_view 16-byte view + text
struct each child's each child's
fixed_size_list ``list_size`` x the child's the child's
list, map offset (4, ``large_list``: 8) the child's, empty
dictionary index ``bit_width / 8`` one dictionary value
union, list view 16, a rough guess
======================== ================================ ====================
"""

I checked the widths against what PyArrow 21 allocates for 5,000 rows, and they hold. Two cases overcount, both in the safe direction:

  • PyArrow allocates no bitmap for a column with no nulls, so path and Hive partition columns are charged 625 B too many per 5,000 rows.
  • A view type keeps a value of 12 bytes or less inside its 16-byte view, so short values are charged their text twice ("2024" as string_view: 80,000 B held, about 100,600 charged).

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.

Applied, with the two overcounts noted under the table. Thanks for checking the widths.

@goutamvenkat-anyscale
goutamvenkat-anyscale merged commit f3a0954 into master Nov 13, 2026
6 checks passed
@goutamvenkat-anyscale
goutamvenkat-anyscale deleted the aarrya/decoded-size-3-ray-read branch November 13, 2026 23:07
eugenepaniot added a commit to eugenepaniot/ray that referenced this pull request Nov 19, 2026
…floop-input

* upstream/master:
  [Data][3/n] update progress bar on lineage reconstruction (ray-project#67366)
  [Data] Enable the Top-N rewrite by default and expose it on DataContext (ray-project#68329)
  [Data] Adaptively skip map-side partial aggregation for high-cardinality keys (ray-project#68118)
  [Core] Spawn specific servers without preexec_fn to fix intermittent startup crashes (ray-project#67947)
  [Serve] Stop the __wrapped__ walk at non-callables (ray-project#67117)
  [Data] Deflake test_read_parquet_v2 by cutting redundant Ray Data executions (ray-project#68318)
  [Data] Retry FooterReader actor deaths with Ray Core and yield footers in listing order (ray-project#67988)
  [Data] Fix order-dependent schema unification when a list<null> arm is present (ray-project#68259)
  [Serve] Make @serve.batch work when wrapped in another decorator (ray-project#68177)
  [serve] Deflake test_metrics_3 - record the batch queue length once a batch is taken (ray-project#68302)
  [serve] Drop completed requests from the multiplexed model ID index (ray-project#68085)
  [Data] Fix flaky test_hudi: read each table once instead of sorting in Ray Data, keep size small (ray-project#68162)
  [Data] Fix flaky test_context: start 2 Ray clusters instead of 5 and keep size small (ray-project#68161)
  [Data] Fix flaky test_kafka: use recent timestamps in test_read_kafka_datetime_partial_range (ray-project#68248)
  [Data] Iceberg DSv2 [2/5]: The listing-to-reading manifest for Iceberg (ray-project#67951)
  [Train] Report training errors when the post-mortem debugger raises a BaseException (ray-project#68317)
  [RLlib] Skip the PPOConfig docstring example that crashes the rllib doctest target (ray-project#68306)
  [Train] Support post-mortem debugging for training function errors (ray-project#68296)
  [train][1/n] Give each health probe its own timeout (ray-project#68191)
  [Data] Fix unifying a fixed-shape tensor array with a lower-ndim variable-shaped one (ray-project#67266)
  [Train] Add a guide to debugging failures and hangs (ray-project#68299)
  [Data] Persist BlockMetadata.num_rows and batch ray.get in _calculate_blocks_rows (ray-project#67662)
  [Data] Vectorize LeRobot delta segment preparation and validate index contiguity (ray-project#67845)
  [Data] Avoid full-DataFrame apply in _AbstractKBinsDiscretizer._transform_pandas (ray-project#67862)
  [doc] Refresh intersphinx inventory snapshots (ray-project#68303)
  [Data] Fix SimpleImputer on categorical columns in append mode and with existing category values (ray-project#67467)
  [Data] Replace O(N) list.pop(0) with deque.popleft() in PushBasedShuffleTaskScheduler (ray-project#67243)
  [Train] Reject an elastic ScalingConfig with max_workers=0 (ray-project#68218)
  [core][move semantics][3/n]Populate task args with is_move for movable refs (ray-project#66803)
  [core][sandbox] Remove the readonly option (ray-project#68088)
  [Data](1/n) Implement the line-chunk reader for CSV and JSONL on DataSource V2 (ray-project#67907)
  [Data] Set MIMALLOC_PURGE_DELAY=0 on random_shuffle to fix the pyarrow 25 OOM regression (ray-project#68151)
  [core] Quote each `uv run` argument in the uv runtime env hook (ray-project#68156)
  [core] Don't let gRPC cancel calls that wait over 30s in the server queue (ray-project#68210)
  [Data] Fix shuffle and join on native tensor columns with pyarrow 25+ (ray-project#68072)
  [serve][llm] Remove decode load progress (ray-project#68258)
  [ci] Bump sglang to 0.5.23 in release tests (ray-project#68250)
  [Core] Build the test auth token file locally so Windows tests can read it (ray-project#68262)
  [image] Bump EFA installer to 1.51.0 in CPU base-extra images (ray-project#67730)
  [serve] Observe the result of rank reassignment reconfigures (ray-project#67923)
  [Serve][Docs] Explain imperative vs declarative deploys and in-place updates from Python (ray-project#68243)
  [Data] (Fault tolerance) Ray Data lineage reconstruction docs (ray-project#68061)
  [RLlib] Add a multi-node footsies APPO memory release test (ray-project#67595)
  [Train] Remove local mode (ray-project#68239)
  [Data] Fix filtered Lance row-count metadata (ray-project#67228)
  [Serve][2/2] Propagate TracingConfig to proxies at startup (ray-project#65437)
  [Data] Fix synthesized path filtering in DataSourceV2 (ray-project#67079)
  [RLlib] Run the BCConfig Tune example one trial at a time to unblock the rllib doctest target (ray-project#68242)
  [Data][Delta DSv2][2/7] List Delta Lake table files from the log (ray-project#67888)
  [Data] Parallelize Parquet and ORC full-schema reads (ray-project#67542)
  [Data] Random Shuffle on Shuffle V2 Map/Reduce Operators (ray-project#68004)
  [Data] Propagate metadata prefetch thread failures to executor (ray-project#68171)
  [core] Send generator consumed-progress updates from io_service_ (ray-project#67160)
  [Data] Add @ray-data-connectors as codeowner for datasource/sinks files (ray-project#68154)
  [data][llm] Keep the prompt in vLLM error rows (ray-project#67665)
  [data][actor-only][3/n] Actor-only backend: operator fusion (ray-project#67699)
  [Data] Read text files on DataSource v2 (ray-project#68063)
  [Autoscaler][KubeRay] Never patch worker group replicas below minReplicas (ray-project#67332)
  [Serve] Show progress of updating (ray-project#67107)
  [core][test] Trigger usage-stats OOM test without exhausting host memory (ray-project#68009)
  [Serve] Remove unused RAY_SERVE_HAPROXY_INGRESS_RETRY_ON and RAY_SERV… (ray-project#68175)
  [Data] Implement lineage tracker garbage collection upon marking operator durable (ray-project#67788)
  [Core] Fix recovery suppression race in ObjectRecoveryManager (ray-project#64974)
  [serve] Pass grpc.so_reuseport to gRPC as an integer (ray-project#66816)
  [Autoscaler][v2] Preserve retry accounting when trimming status history (ray-project#67360)
  [doc] Refresh intersphinx inventory snapshots (ray-project#68069)
  [Doc] Add item to AGENTS.md to update documentation when modifying API-facing code. (ray-project#68204)
  [Train] Preserve `num_boost_round=0` and avoid mutating `callbacks` in legacy LightGBM/XGBoost trainers (ray-project#68145)
  [Train] Raise in prepare_data_loader instead of dropping a custom batch_sampler (ray-project#68201)
  [air] Return None in skip_exceptions when exc or StartTraceback cause is None (ray-project#68172)
  [Train] Fix `checkpoint_manager` to support metrics only reported in a validation function (ray-project#67909)
  [Train] Count elastic workers in resource units for fractional resources (ray-project#68139)
  [Data] Refactor Disk shuffle map to use map Operator (ray-project#67130)
  [core][move semantics][2/n] Change state to moved on consumption and add enforcements (ray-project#66767)
  [Data] Propagate labels to object-store SHUFFLE_V2 map/reduce tasks (ray-project#67135)
  feat(core): add Cambricon MLU resource support (ray-project#66368)
  [Data] Make `zero_copy_batch=False` copy default batches (ray-project#67154)
  [data] Fix Parquet filename suffix detection (ray-project#67156)
  [data] Fix docstring/behavior mismatches in read_json and Dataset.sort (ray-project#66927)
  [Data] Run video_object_detection.ray on T4s with more memory (ray-project#68149)
  [core][sandbox] Let a node override network="public" sandboxes' default resolvers (ray-project#67691)
  [Data] read_mcap: resolve each sample's steps and lay out its row (ray-project#67925)
  [Data] read_mcap: sample read inputs: TopicSpec, steps, match and samples checks (ray-project#67924)
  [Data] Keep a map task's buffered rows when max_errored_blocks skips its error; read past corrupt MCAP chunks (ray-project#67167)
  [core][move semantics][1/n] Adding consume_once flag in actor methods (ray-project#66620)
  [Data] Size the schema pin and the columns Ray adds in the Parquet decoded-size estimate [3/6] (ray-project#67838)
  [Serve][LLM][1/3] Token based autoscaling: track autoscaling workload in KV router (ray-project#67937)
  [Data] Add native direct reads for nonpartitioned Hive tables (ray-project#67114)
  [Train] Count elastic workers in resource units for fractional resources (ray-project#68139)
  [Data] Add `condition` to `Dataset.join` and extract equi-join keys from it (ray-project#67590)
  [data] Add Top-N execution (ray-project#66931)
  [build] Bazel 8.8.1: bump protobuf to v29.6, rules_java to 8.12.0 and gRPC to 1.69.0 (ray-project#66483)
  [build] Use Arena::Create and pin Java 8 bytecode ahead of protobuf 29 / rules_java 8 (ray-project#67720)
  [core][sandbox] Don't join a sandbox's cgroup on every exec (ray-project#67690)
  [Data] Run `training_ingest_regression_test` on Instances that can be Provisioned (ray-project#68110)
  [Data] Run Sort on Disk-based Shuffle under SHUFFLE_V2 (ray-project#67850)
  [core] Deflake tests that race on timing (ray-project#67717)
  [ci] Bump pypa manylinux2014 base image to 2026.10.22-0 for CPython 3.15 (ray-project#67285)
  [Data] Make Mcap Data Column Test Insensitive to Struct Field Order (ray-project#68109)
  [Data] read_mcap V2: cut large files where their log-time order holds (ray-project#67166)
  [core][sandbox] Commit sandbox as new registry image (ray-project#67972)
  [Data] read_mcap V2: read neighbouring chunks in one ranged request (ray-project#67930)
  [train][4/n] Wire WorkerProbes through the HealthManager (ray-project#67915)
  [train][3/n] Add WorkerProbe results and health reports to the HealthState (ray-project#67879)
  [Data] (Data fault tolerance ray-project#6/6) Add a manual release test for lineage reconstruction (ray-project#67519)
  [train][6/n] Act on health decisions in the Ray Train controller (ray-project#67856)
  [Train] Do not start an elastic worker group with zero workers (ray-project#68101)
  [Train] Keep the last checkpoint after a metrics-only report in local mode (ray-project#68070)
  [Data][2/n] Migrate GPU Shuffle to Unified Phase Metrics (ray-project#67359)
  [Data][Chkpt] Fix `ArrowInvalid` when loading large generated-ID checkpoints (ray-project#68065)
  [core][test] Create auth token in test_redis_wrong_password (ray-project#68014)
  [data][actor-only][2/n] Actor-only backend: promote task pools to actor pools (ray-project#67698)
  [Data] Fix typing mismatches in Dataset public API (ray-project#62077)
  [Data] read_mcap V2: carry read tasks' summary records in the manifest (ray-project#67929)
  [Data] Distinguish generated ID collisions with synthesized columns (ray-project#67164)
  [Data] Fix incorrect scale-up in rate-based autoscaler for custom resources (ray-project#66647)
  [Data][Delta DSv2][1/7] Shared Parquet and partitioning fixes for the Delta reader (ray-project#67887)
  [Data] Eliminate redundant aggregation shuffle (ray-project#67198)
  [Data] Raise minimum supported pyarrow to 23.0.0 and test up to 26.0.1 (ray-project#68005)
  [Train] Use the default validation timeout when a report's ValidationTaskConfig has none (ray-project#68045)
  [doc][train] Use the global batch size in the TensorFlow Train examples (ray-project#68006)
  [TPU] Default multi-slice MASTER_ADDR to slice 0 host 0 in SlicePlacementGroup (ray-project#67878)
  [Data] Estimate a Parquet row group's decoded Arrow bytes from its footer [2/6] (ray-project#67837)
  [Data] Predicate pushdown through joins: split conjuncts, derive one-sided OR weakenings (ray-project#67122)
  [Data] Add partition_filters to read_delta and take file sizes from the log (ray-project#67900)
  [Data] Stop writing Unity Catalog vended credentials to the environment (ray-project#67899)
  [Data] Raise an error for Delta tables with column mapping in write_delta (ray-project#67898)
  [Core] Add initial foundational configurations and flags for fork server (ray-project#67356)
  [core][sandbox] Image layers caching (ray-project#67874)
  [Doc][Train] Add device stream batch prefetching section to accelerator guide (ray-project#67779)
  [Train] Use user-defined train function name in training thread name and error stack traces (ray-project#64292)
  [serve][docs] Remove beta label from custom autoscaling policies (ray-project#68046)
  [core] Don't treat a gRPC client with calls in flight as idle (ray-project#67718)
  [train] Fix checkpoint sorting to support nested metrics (ray-project#59130)
  [train][5/n] Run ControllerProbes on the controller's node monitor (ray-project#67671)
  [Train] Rank a checkpoint without the score attribute as worst in min order (ray-project#67901)
  [Core][RuntimeEnv] Stream runtime environment package downloads (ray-project#67184)
  [core] Deflake `_run_hanging_command` tests (ray-project#67461)
  [Data] Add Gravitino Iceberg REST catalog provider (ray-project#67007)
  [Data] Fix mixed-root partition filtering in Parquet and ORC V2 (ray-project#67067)
  [core] Keep absl logging at ERROR unless GRPC_VERBOSITY is set (ray-project#67719)
  [Data][1/n]Add Shuffle Metrics Unification Instrumentation (ray-project#66968)
  [ci][release] Stop publishing Python 3.10 wheels and images (ray-project#67722)
  [serve] Copy the ASGI lifespan state into each request scope (ray-project#67844)
  [Serve][LLM][4/5] Support scale-to-zero application routing (ray-project#67087)
  [core][sandbox] Let GPU sandboxes request NVIDIA profiling capabilities (ray-project#67974)
  [Serve][LLM] Exclude LLMRouter from dashboard QPS (ray-project#67873)
  [Data] Read the Parquet SizeStatistics PyArrow doesn't expose [1/6] (ray-project#67836)
  Add perf metrics for 2.60.0 (ray-project#67727)
  [Observability / Train] Add Grafana Annotation support with Ray Train usage (ray-project#66958)

Signed-off-by: Eugene Paniot <[email protected]>

# Conflicts:
#	python/ray/data/_internal/planner/plan_udf_map_op.py
goutamvenkat-anyscale added a commit that referenced this pull request Nov 24, 2026
…om its footer [4/6] (#67839)

## Description

Stacked on #67838.

A read task's memory peaks while PyArrow decodes a row group, well above
the decoded Arrow bytes #67837 estimates. For 200,000 rows of an `int64`
and a `double` column, the decoded table is 3.1 MiB but PyArrow's memory
pool peaks at 8.9 MiB when a read task scans it.
`parquet_decode_peak.py` estimates that peak from the footer, without
decoding anything: 9.8 MiB here. Nothing calls it yet, so behavior
doesn't change.

The inputs are the footer as PyArrow parses it, the `SizeStatistics`
#67836 reads from it, the file's size from the listing, and how many CPU
threads PyArrow decodes on.

A column, as `columns=` names it, is stored as one or more leaves,
Parquet's primitive columns: an `int64` column has one leaf, a
`struct<a: int64, b: string>` two. Each of PyArrow's CPU threads decodes
one column at a time, and a column's leaves one after another. A leaf's
buffers are either kept until its column is read or temporary, freed
once that leaf is decoded. Once a column is read, only its decoded
values stay. A Ray read task gives PyArrow one CPU thread
(`RAY_DATA_PARQUET_READER_CPU_COUNT`, which #67840 passes in).

```mermaid
flowchart TD
    F["Footer and its SizeStatistics"] -->|"each leaf's sizes and encodings"| L["estimate_leaf_work, per leaf"]
    L -->|"a column's leaves in turn"| C["Each column's buffers"]
    F -->|"each leaf, #67837"| D["Every column's decoded values"]
    C -->|"the largest, one column per CPU thread"| P["Row group peak"]
    D --> P
    F -->|"80 KiB footer read and gaps + compressed chunks"| P
    S["File size"] -->|"under 48 KiB: the file instead"| P
    X["estimate_cast"] -->|"a pinned schema's cast x 1.5"| P
```

Modelled on PyArrow 24's reader, a row group's peak is the sum of four
parts:

1. **I/O** (`estimate_row_group_peak`): PyArrow's 64 KiB footer read and
up to two of the 8 KiB gaps `pre_buffer` reads between chunks, 80 KiB in
all, plus each chunk's compressed bytes. A file under 48 KiB was read
whole by the footer read, so it's charged its size plus 512 bytes and
256 bytes per leaf read instead.
2. **Every column's decoded values** (#67837).
3. **The buffers of the columns decoding at once**
(`estimate_row_group_work`, `estimate_leaf_work`). A leaf keeps its
`int16` definition and repetition levels, its dictionary plus 16 bytes
an entry for strings (an entry per 4 bytes of dictionary, the most it
can hold), and for a compressed chunk the buffer pages decompress into,
the larger of the chunk's uncompressed bytes and its dictionary page.
DELTA encodings add 4 bytes a value for the lengths they unpack, and
`DELTA_BYTE_ARRAY` its prefix lengths and rebuilt values too. Its
temporaries are offsets reserved past the values used, the string
builder's copy of the values, and list offsets. A column's buffers peak
at one leaf's temporaries on top of what that leaf and the ones before
it keep. The estimate adds the buffers of the `decode_threads` largest
columns, or of every column when it is 0 or less.
4. **A pinned schema's cast** (`estimate_cast`): #67838's estimate of
the cast columns, × 1.5 because casts to text measured higher, plus the
columns Ray adds.

A leaf #67837 doesn't model is left out here; #67840 charges it.

Underestimating is what causes OOMs, so the rules lean high. These
numbers were measured before the review changes to #67838 and not re-run
since. On the bench #67838 describes (10,000 random files, 148,166 row
groups), PyArrow's pool peak was measured for each row group as a read
task scans it: one CPU thread, 16 IO threads. On the 30,127 whose every
leaf and cast the estimate models, none is under 0.95× (the lowest is
0.996×, a 34-row group):

| Estimate ÷ PyArrow's peak | All modelled (30,127) | Peak ≥ 1 MiB
(7,573) |
|---|---|---|
| < 0.95 | 0 | 0 |
| 0.95–1.2 | 10.1% | 18.5% |
| 1.2–1.5 | 34.3% | 46.1% |
| 1.5–2 | 38.6% | 28.9% |
| 2–3 | 16.5% | 6.3% |
| > 3 | 0.5% | 0.3% |
| median / p90 | 1.55× / 2.16× | 1.40× / 1.85× |

Tests: `tests/unit/datasource_v2/test_parquet_decode_peak.py` (new), 6
passed. It writes 200,000-row files (an `int64` and a `double`, a
nullable `int16`, strings with 50,000 distinct values, a list column
read after an `int64` column, and eight list columns on one CPU thread
and on 12), measures PyArrow's peak as a read task scans each one, on
PyArrow's default memory pool in a fresh process, and checks the
estimate lands within 0.95–1.5× of it. The cases need PyArrow ≥ 23 for
`SizeStatistics`.

Signed-off-by: Aarrya <[email protected]>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Aarrya <[email protected]>
Co-authored-by: Goutam <[email protected]>
Co-authored-by: Claude Opus 5.5 <[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