damccorm opened a new pull request, #41799:
URL: https://github.com/apache/beam/pull/41799
Note: this PR was auto-generated by tooling. Before moving it out of draft,
the author has done a full review of the PR, specifically evaluating it on the
following criteria:
- The PR is an appropriate fix for the issue (e.g. we're not changing a test
to avoid a bug)
- The PR is a simple fix to the issue (e.g. we're not adding infra when we
could just modify a test)
- The PR is not covering for other problems (e.g. if we're bumping timeouts,
it is not because we're covering for a performance problem)
Full details of the methodology of generation and review can be found here -
https://docs.google.com/document/d/14lj7ECVov4T4EdwmIzNlWrRGE3lLDMOwX5xUMGzaLoc/edit?usp=sharing
If you have concerns with the PR or with the underlying methodology used to
generate this, please comment below - they will be addressed by the author not
the tooling :)
## Summary
Reduces self-inflicted thread oversubscription in
`UnboundedScheduledExecutorServiceTest.testThreadsAreAddedOnlyAsNeededWithContention`
from `100` concurrent caller threads (`200` total active threads) to `20`
concurrent caller threads (`40` total active threads, asserting `largestPool <=
30`), and includes the actual `largestPool` value in the assertion failure
message.
## Root Cause
`UnboundedScheduledExecutorService` relies on a fixed `10ms`
`SynchronousQueue.offer(r, 10, MILLISECONDS)` wait so idle worker threads
returning from `FutureTask.finishCompletion()` (which unparks the caller's
`.get()`) to `SynchronousQueue.poll()` can be reused instead of spawning new
threads.
Spawning `100` caller threads + `100` worker threads (`200` runnable threads
executing `20,000` `sleep(5)` handoffs) heavily oversubscribes CI runner CPU
cores alongside parallel Gradle test workers. Under heavy load (e.g., build
`46238257894`, which took `2h 19m`), OS scheduling latency easily exceeds
`10ms`, causing `ThreadPoolExecutor` to exceed the hardcoded `120` cap
(previously bumped `104 -> 110` in #30278, reduced from `1000 x 1ms` to `200 x
5ms` in #35045, and bumped `110 -> 120` in #38411):
- [46238257894](https://github.com/apache/beam/actions/runs/46238257894)
(job `141269053218`, `2026-11-29T08:30:18Z`):
`UnboundedScheduledExecutorServiceTest >
testThreadsAreAddedOnlyAsNeededWithContention FAILED` (`AssertionError` at line
628, with no failure message showing `largestPool`).
## Fix
- Scale concurrent caller threads from `100` to `20` (`4,000` sequential
`sleep(5)` handoffs across `40` total threads instead of `200`), reducing OS
scheduler contention by 5x without altering the production `10ms` offer timeout.
- Assert `largestPool <= 30` (accounting for `20` workers + `1`
`TaskLauncher` thread + contention headroom) with a descriptive failure message
reporting the actual `largestPool`.
Test-only change; no production code is modified.
### Verification
- Triggered `beam_PreCommit_Java.yml` workflow run on branch:
[`46492875176`](https://github.com/apache/beam/actions/runs/46492875176)
--
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]