Skip to content

Reuse the decoded schema across shuffle blocks instead of re-parsing it per block #5792

Description

@peterxcli

What is the problem the feature request solves?

Every native shuffle block is a self-contained Arrow IPC stream: schema message, dictionary messages, record batch message, end-of-stream marker. On the read side read_single_batch builds a fresh StreamReader for each block, so the schema flatbuffer is parsed once per block, even though every block in a shuffle carries the same schema and the reducer already knows that schema from the plan protobuf (ShuffleScanExec builds it from data_types).

The write side already avoids the mirror image of this cost. ShuffleBlockWriter encodes the schema flatbuffer once in try_new and writes those pre-encoded bytes verbatim at the start of every block (SchemaEncoding::Precoded) rather than re-serializing per block. The reader has no equivalent.

Blocks per reduce task scale with the number of mappers times the number of blocks each mapper wrote for that partition, and a mapper writes at least one block per spill round, so this grows with both cluster width and memory pressure.

Describe the potential solution

The cost to remove is the flatbuffer parse and StreamReader setup, not I/O: the schema message sits inside the compressed stream and is decompressed either way. A reader that caches the parsed schema and skips re-parsing when a block's decompressed schema message matches the cached bytes would keep the current block format intact.

Dropping the schema message from the format outright would be cheaper still, since the reducer does not need it, but that changes the wire format and would have to account for the RSS path and for the dictionary-schema fallback, which does not use Precoded.

Unmeasured so far. Worth a read-side benchmark at a high mapper count before acting.

Additional context

No response

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions