zhangshenghang opened a new issue, #13355: URL: https://github.com/apache/seatunnel/issues/13355
### Search before asking - [x] I searched existing issues and PRs before filing this report. - [x] This report is based on source analysis at commit [`5e0e9c8e3f`](https://github.com/apache/seatunnel/commit/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff); line numbers may drift on `dev`. - [x] Related existing work: #11663 / #12087 (autoscaling), #13349 (snapshot-based allocation), #13354 (static-slot observability). ### What happened Fixed-slot mode creates `slot-num` `SlotProfile` objects per worker and then repeatedly serializes and scans all of them: 1. **Heartbeat payload is O(slot-num) every 5 seconds.** `getWorkerProfile()` copies the complete `assignedSlots` and `unassignedSlots` arrays, and `WorkerHeartbeatOperation` sends the whole profile to the master: [`DefaultSlotService.java#L113-L155`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/service/slot/DefaultSlotService.java#L113-L155) [`DefaultSlotService.java#L306-L315`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/service/slot/DefaultSlotService.java#L306-L315) With the default `slot-num = availableProcessors() * 2`, a 64-core worker sends 128 slot profiles every 5s; a larger or misconfigured `slot-num` makes this proportionally worse. 2. **`getWorkerProfile()` and `requestSlot()` are both `synchronized` on the slot service.** Every slot assignment/release and every heartbeat construction serializes on the same monitor: [`DefaultSlotService.java#L171-L193`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/service/slot/DefaultSlotService.java#L171-L193) [`DefaultSlotService.java#L205-L235`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/service/slot/DefaultSlotService.java#L205-L235) 3. **Slot selection scans all unassigned slots.** `selectBestMatchSlot()` streams over `unassignedSlots`, filters by `enoughThan`, and takes the minimum, i.e. O(slot-num) per request: [`DefaultSlotService.java#L249-L288`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/service/slot/DefaultSlotService.java#L249-L288) 4. **One `RequestSlotOperation` per task group.** `ResourceUtils.applyResourceForTask()` is called separately for every vertex, so a job with N task groups issues N RPCs; there is no batch allocation: [`ResourceUtils.java#L99-L112`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/ResourceUtils.java#L99-L112) ### Impact - Large fixed pools pay continuous CPU/network cost for heartbeats even when nothing changes. - Allocation latency grows with `slot-num` because every request scans the free set and serializes with heartbeat construction. - Under a burst of task-group requests, the worker-side `synchronized` bottleneck can serialize allocation for the whole worker. - The default `slot-num = 2 * CPU` can be large on modern machines; the cost is paid even when the job only needs a few slots. ### Expected behavior - Heartbeats should carry a compact summary or a delta (for example free slot count, assigned count, a profile version, and only changed assignments), not a full array every 5s. - Slot selection should use an index (for example a `TreeMap<memory, slot>` or per-size free lists) instead of scanning all slots. - Slot requests should be batchable per worker so a job's N task groups can be satisfied with one request and one atomic selection. - The per-worker allocation monitor should not block heartbeat construction or unrelated slot queries. ### Suggested fix direction 1. Add a profile version/epoch and send a delta or summary; the master already has the full profile after the initial sync. 2. Maintain a free-slot index in `DefaultSlotService` keyed by resource profile (and a plain count for the common identical-slot case), so selection is O(log n) or O(1). 3. Add a `RequestSlotsOperation(jobId, List<ResourceProfile>)` that allocates N slots atomically on the worker; use it from `ResourceRequestHandler`. 4. Add a benchmark/IT with `slot-num = 512` and assert heartbeat size/allocation latency stays bounded. ### SeaTunnel version `dev` (analyzed at `5e0e9c8e3f`). ### Zeta or Flink or Spark Version Zeta. ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
