fix: cut JVM columnar shuffle batches by bytes as well as rows #7787
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.46) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 476 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.369
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #7787"
general
weight: 0.35
sunchao
Which issue does this PR close?
Closes #7497. Part of #7267. The one case left, a single row whose string decodes past 2 GiB, is #7803.
Rationale for this change
The JVM columnar shuffle converts sorted UnsafeRows to Arrow in batches of
spark.comet.shuffle.jvm.batchSizerows (capped byspark.comet.batchSize). Both entry points,process_sorted_row_partitionand the sort-basedprocess_sorted_partitions, cut batches by row count only. Arrow indexes a string or binary column's values with i32 offsets, so once one column of one batch passes 2 GiB (about 256 KiB per value at 8192 rows) the task panics withbyte array offset overflow, or fails withOffsetOverflowErrorwhen a dictionary column falls back to plain values. Spark shuffles rows and has no batch to overflow, so the same query succeeds without Comet. The only workaround was lowering the batch size for every shuffle.What changes are included in this PR?
BatchLimits::has_room). A row's size bounds what it adds to any one binary column, including values nested in arrays, maps and structs, so the cut needs no look at the values. A batch always takes its first row.get_stringreplaces each invalid UTF-8 byte with the three bytes ofU+FFFD, so when the schema holds a string anywhere, each row counts three times (row_weight). One column of a batch then holds at most about 1 GiB even if every byte is invalid.i32::MAX, which the block writer and the JVM reader (NativeBatchDecoderIterator) cannot take,encode_batchdrops it before it reaches the checksum or the file and encodes each half instead. The buffer gives back the capacity afterwards.*_withinfunctions asBatchLimits, so tests can inject small ones. The public signatures and the JNI call sites are unchanged.jvm_shuffle.md, the config tables injvm_shuffle.mdandnative_shuffle.md, the Batch Size section ofmemory.md, and the.doc(...)ofspark.comet.shuffle.jvm.batchSize.How are these changes tested?
sorted_row_partition_ends_batches_at_the_byte_budget: six batch-size and budget combinations throughprocess_sorted_row_partition, including a budget below one row; checks the blocks written and that the values read back unchanged and in order.sorted_partitions_end_batches_at_the_byte_budget: records laid out in a page as Spark's sorter stores them, across two partitions and an empty one; checks the blocks per partition,partition_lengthsagainst the file, and the round-tripped values.row_weight_triples_rows_whose_schema_holds_a_stringandstring_columns_budget_for_invalid_utf8_tripling: nested schemas, and a budget that holds three binary rows but one string row.oversized_blocks_are_split_before_the_checksum_and_the_file: a small injected block limit halves the batch, or splits it down to single rows, and the returned checksum matches the file's bytes.#[ignore], need several GiB, run locally with--ignored:invalid_utf8_strings_tripled_past_2_gib_do_not_overflowandblocks_past_i32_max_from_null_structs_are_splitrebuild both cases from the review at full size. Each checks that the old cut fails (overflow, orexceeds maximum sizefrom the block writer) and that the new one writes every row intact.CometShuffleSuite,DisableAQECometShuffleSuiteandCometShuffleChecksumDisabledSuitepass.