Skip to content

fix: concurrent builder correctness, timing, and maintainability - #14219

Open
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:fix/concurrent-builder-review-fixes
Open

gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:fix/concurrent-builder-review-fixes

Conversation

@gnodet

@gnodet gnodet commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix BuildSuccess wallTime/execTime swap: the 3-arg constructor passed arguments to BuildSummary in the wrong order, reversing wall and exec times in build summaries for the concurrent builder
  • Fix PhasingExecutor.phase() premature exit: the completion condition (completedCount - start < activeCount) could exit while tasks were still spawning recursive work; simplified to while (activeCount > 0)
  • Replace Clock class with step-based timing: the shared mutable Clock had data races with concurrent V4 mojo steps (overlapping start()/stop() pairs corrupt resumed/exec). TEARDOWN now computes timing by scanning each step's startTime/endTime — no shared state
  • Remove dead code: global clock (started but never stopped), redundant write lock around plan(), computeForkPlan loop in plan() whose result was discarded
  • Decompose processStep (110 lines → 15): extracted isCleanupAfterStep, shouldExecute, submitStepForExecution, logSkipReason; unified two duplicated executor.execute() patterns into one
  • Document merge invariant: BuildStep.predecessors (HashSet) and successors (CopyOnWriteArraySet) must deduplicate by equals — BuildPlan.merge() relies on this to prevent orphaned step references that would cause deadlocks

Test plan

  • New test: testMergePlanSegmentsDeduplicatesPredecessors — verifies merge deduplication prevents orphaned predecessors
  • New test: phaseWaitsForRecursivelySpawnedTasks — verifies PhasingExecutor.phase() waits for all recursive work
  • All existing concurrent builder tests pass (71 tests in maven-core + 2 in maven-impl)

🤖 Generated with Claude Code

- Fix BuildSuccess swapping wallTime/execTime when calling super(),
  causing reversed timing in build summaries for the concurrent builder
- Fix PhasingExecutor.phase() premature exit when tasks spawn recursive
  work (completedCount vs activeCount condition was insufficient)
- Remove redundant write lock acquisition around plan() call
- Replace Clock class with step-based timing computation in TEARDOWN,
  eliminating shared mutable state and concurrent access issues
- Remove dead global clock (start() called but stop() never called)
- Remove dead computeForkPlan loop in plan() whose result was discarded
- Decompose 110-line processStep into focused methods: isCleanupAfterStep,
  shouldExecute, submitStepForExecution, logSkipReason
- Unify two duplicated executor.execute() submission patterns into one
- Document merge invariant on BuildStep predecessors/successors collections
- Add tests for plan merge deduplication, PhasingExecutor recursive-spawn,
  and merge invariant protection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant