feat: enhance MultiThreadedBuilder with smart project scheduling #10893
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This enhancement improves parallel build efficiency by implementing intelligent project scheduling based on dependency chain analysis, inspired by the Takari Smart Builder approach.
Key Improvements
SmartProjectComparator
weight = 1 + max(downstream_project_weights)
Enhanced ConcurrencyDependencyGraph
Clean Implementation
Algorithm Details
For a project dependency graph like:
Weights are calculated as:
Build order: A (weight=3), then B and C (weight=2, ordered by project ID), then D (weight=1)
Note: Projects with identical weights are ordered by project ID for deterministic results, not by original declaration order.
Benefits
Usage
The enhancement automatically activates when using multithreaded builds:
mvn clean install -T 4 # Uses 4 threads with smart scheduling
Testing
Includes comprehensive unit tests for:
Compatibility
This enhancement provides immediate performance improvements for multi-module Maven projects while maintaining a clean, focused implementation that aligns with Maven's architecture principles.
Pull Request opened by Augment Code with guidance from the PR author