atognolas opened a new pull request, #39156: URL: https://github.com/apache/beam/pull/39156
## Summary - Replace `GroupIntoBatches` with `GroupByKey` for bounded (batch) inputs in `WriteToPartitions` - Keep `GroupIntoBatches` only for unbounded (streaming) inputs where triggering semantics and optional `autoSharding` (via `withShardedKey`) are needed - `GroupIntoBatches.ofByteSize()` materializes all values for a key into a Java `List` in memory — `RowCoder` reports wire size (~500 bytes/row) but actual heap is ~10× higher for nested schemas ## Motivation Observed OOM on production pipelines with nested schemas (99 columns, 3 protobuf structs): - `n4-standard-16` (64GB): GC thrashing at 99.79%, SDK harness killed - `n4-highmem-48` (384GB): 277GB/377GB heap used for a single batch `GroupByKey` returns a lazy `Iterable` backed by the shuffle service, consuming constant ~100MB memory regardless of partition size. ## Impact - **Batch**: lazy iteration, O(100MB) memory regardless of shard size - **Streaming**: unchanged — `GroupIntoBatches` with triggering + optional `autoSharding` - `autoSharding` only meaningful for streaming (Dataflow dynamic key splitting) ## Test plan - [ ] Existing `WriteToPartitionsTest` passes - [ ] Run IcebergIO integration tests for both batch and streaming - [ ] Verify no OOM on large-partition batch pipelines 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
