Repository navigation
Conversation
… pool A spill sorts its buffered batches inside a SpillWorkspace that grows its first parent with the infallible grow (29b0bb0), since what the merge's children record there already exists. Late materialization's Gather also asks that workspace, with try_grow, before it concatenates a group of column pieces, and the copy it would make is new memory. In a spill workspace that try_grow never failed, so the concatenation went ahead past Spark's grant and Comet carried the difference as overcommit. When the batches' columns share one allocation, as batches decoded from shuffle do, no piece is freed until the batch's last column is concatenated, so a spill held up to about twice its input. On em32 parse_parquet device_default this put 8 tasks' native reservations at 12.8 GiB against a 9 GiB grant (OVERCOMMIT_DIAG: every overcommit step came from Gather::concatenate under sort_and_spill) and the pods were killed with exit 137. The sorted runs of a late-materialized sort now register with a bounded view of the workspace whose try_grow stays under the execution pool's limits, while grow still records existing memory without limit. A concatenation the pool refuses is skipped and the columns are gathered from their pieces. Gather also reserves the concatenated array's actual size before keeping it, not only its sliced size. The streaming merge of non-late runs keeps the infallible workspace, so the failure 29b0bb0 fixed does not return. Tests: a bounded workspace view refuses growth past the pool and still accepts grow; a late-materialized spill of batches sharing one allocation per batch peaks within the pool for three pool sizes and five orderings (before: 2997665 of 2283968 bytes). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Local JVM suites (Spark 3.5, release lib from this branch): CometExecSuite, CometWindowExecSuite, CometPartitionAggregateWindowSuite, CometJoinSuite, WideRowSortFallbackSuite, CometTaskMetricsSuite and CometTPCDSV1_4/V2_7 PlanStabilitySuite: 532 succeeded, 0 failed, 2 canceled (Spark 4.x-only tests). GCP, parse_parquet device_default for MSK day 2026-10-12, em32 9g/12g/5g (26 GiB pod), 11 executors:
Output compared with the 1.1-9 run: 897 event types and 815 472 571 rows in both, with the same event_id key sets in every type. The value differences are the dedup tie-break among duplicate ids, which is nondeterministic in vanilla as well. 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On em32 (9g heap / 12g off-heap / 5g overhead, 26 GiB pod)
parse_parquetdevice_default with Comet joom-1.1-9 lost 5 of 11 executors to exit 137. At a death, Spark had granted 8 tasks 9 GiB off-heap, but Comet's native pools held 12.8 GiB ("allocated 12926 MiB, reserved 12810 MiB (8 plans)"). The pools carried the difference as overcommit.A diagnostic build logged every 256 MiB of overcommit with its consumer and native stack. Every entry was
ExternalSorter→SpillWorkspace::cover→Gather::concatenate→Gather::try_new, undersort_and_spill(the dedup sort, ~600–1000 GB of spill).Cause
29b0bb0 made a spill's
SpillWorkspacegrow infallibly. Its reasoning was that everything the merge's children record already exists. That is true for the streaming merge of sorted runs. It is not true for late materialization:Gather::mergecallstry_growbefore it concatenates a group of column pieces, and the copy is new memory.try_growcould never fail.Batches decoded from shuffle share one IPC body allocation per batch. So no piece is freed until the batch's last column has been concatenated, and a spill held up to about twice its input past Spark's grant.
Fix
SpillWorkspace::bounded(). This is a view whosetry_growstays under the execution pool's limits.growstill records existing memory without a limit.Gather::mergealso reserves the concatenated array's actual size (get_array_memory_size) before keeping it, not just its sliced size.merchants_lifecyclefailure that 29b0bb0 fixed does not come back.Tests
spill_workspace::a_bounded_view_of_a_spill_workspace_refuses_growth_past_the_poollate_materialize::a_spill_concatenates_only_what_the_pool_grants: batches sharing one allocation per batch (IPC round trip), 5 orderings × 3 pool sizes. It asserts peak ≤ pool limit, output matches the reference, and the pool is empty at the end.sorttests pass: 27.🤖 Generated with Claude Code