gnodet opened a new pull request, #14193: URL: https://github.com/apache/maven/pull/14193
## Summary - Add weight-based critical-path scheduling to the concurrent builder (`-bconcurrent`). Each `BuildStep` gets a weight equal to the longest weighted path from it to any terminal step, computed via a reverse topological pass in `BuildPlan.computeWeights()`. The existing `executePlan()` scan sorts ready steps by weight descending before submitting them. - By default, graph depth is used as the weight heuristic (each step has `selfWeight = 1`), which ensures steps on the longest dependency chain are prioritized first — a significant improvement over the unweighted scan. - Optionally, when `-Dmaven.builder.stepTimings.enabled=true`, step durations are persisted to `.mvn/target/step-timings.txt` after each build and loaded at the start of the next build. This allows the scheduler to use measured durations instead of depth, which helps when the critical path by time differs from the critical path by depth. ### Benchmark results (synthetic project, `-T2`) | Configuration | Median | Range | |---|---|---| | Master default (`-T2`) | 18.1s | 15.4–18.4s | | Depth-only critical path | 14.7s | 14.6–15.7s | | Duration-based (with timings) | 14.5s | 14.4–14.9s | The depth-only heuristic provides ~19% improvement with zero infrastructure cost. Duration-based adds marginal further improvement (~1-2%) with notably lower variance. ### Changes - **`BuildStep`**: added `weight` (long), `startTime`/`endTime` (Instant), and `stepId()` method - **`BuildPlan.computeWeights()`**: reverse topological pass computing `selfWeight + max(successorWeight)` - **`BuildPlanExecutor.executePlan()`**: sorts ready steps by weight descending via `.sorted(Comparator.comparingLong(…).reversed())` - **`BuildPlanExecutor.executeStep()`**: records `startTime`/`endTime` in a try/finally block - **`BuildPlanExecutor.plan()`**: loads previous timings (when enabled) and calls `computeWeights()` - **`BuildPlanExecutor.close()`**: writes step timings (when enabled) after executor shutdown - **`StepTimings`** (new): reads/writes `.mvn/target/step-timings.txt` with atomic temp-file-and-move pattern - **`Constants.MAVEN_BUILDER_STEP_TIMINGS_ENABLED`**: new user property (`maven.builder.stepTimings.enabled`, default `false`) ## Test plan - [x] Existing `BuildPlanCreatorTest`, `BuildPlanExecutorTest`, `BuildStepTest` pass (29 tests) - [x] Spotless formatting check passes - [x] Compilation succeeds - [ ] Integration tests via CI - [ ] Manual test with multi-module project using `-bconcurrent -T2` - [ ] Manual test with `-Dmaven.builder.stepTimings.enabled=true` across two consecutive builds _Claude Code on behalf of Guillaume Nodet_ 🤖 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]
