gnodet opened a new pull request, #12654: URL: https://github.com/apache/maven/pull/12654
## Summary During parallel model building (`-T1C`), multiple `PhasingExecutor` threads log concurrently via: ``` SLF4J → MavenSimpleLogger → ProjectBuildLogAppender → SimpleBuildEventListener → PrintWriter.println() ``` Since `PrintWriter.println()` is `synchronized`, all threads serialize on every log call. JFR profiling on a 4383-module diamond-graph project shows **1,470ms of blocked time** from this single contention point — the #1 source of lock contention during `validate`. ### Fix `AsyncDrainWriter` wraps the `Consumer<String>` writer with a lock-free queue + non-blocking drain: - **Producers** enqueue messages into a `ConcurrentLinkedQueue` (CAS, no blocking) - **At most one thread** drains the queue to the underlying `PrintWriter` (via `ReentrantLock.tryLock()`) - **Other threads** return immediately after enqueue — their messages are picked up by the active drain - **`close()`** performs a final blocking drain to guarantee no messages are lost ### JFR Results (4383-module diamond project, `validate -T1C`) | Source | Before | After | |--------|:------:|:-----:| | PrintWriter contention | 1,470ms | **0ms** | | PhasingExecutor contention | 546ms | **49ms** | ### Benchmark (10 runs) | Metric | Before | After | Δ | |--------|:------:|:-----:|:-:| | Median | 14.738s | 14.253s | **-485ms (-3.3%)** | | Average | 14.546s | 14.242s | **-304ms (-2.1%)** | | Range (variance) | 2.70s | 1.33s | **Halved** | All 8,766 module log lines verified present — zero messages lost. ## Test plan - [x] Verified 8,766/8,766 module log lines present (no lost messages) - [x] JFR confirms PrintWriter contention eliminated (1,470ms → 0ms) - [x] `maven-core` unit tests pass - [x] `maven-cli` unit tests pass - [ ] CI passes 🤖 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]
