You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2020/02/23 08:13:02 UTC

[GitHub] [maven] eolivelli commented on a change in pull request #290: [MNG-6774] - Speedup project graph build by paralleling operations

eolivelli commented on a change in pull request #290: [MNG-6774] - Speedup project graph build by paralleling operations
URL: https://github.com/apache/maven/pull/290#discussion_r382975564
 
 

 ##########
 File path: maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
 ##########
 @@ -362,30 +370,42 @@ private ModelSource createStubModelSource( Artifact artifact )
     public List<ProjectBuildingResult> build( List<File> pomFiles, boolean recursive, ProjectBuildingRequest request )
         throws ProjectBuildingException
     {
-        List<ProjectBuildingResult> results = new ArrayList<>();
+        List<ProjectBuildingResult> results = synchronizedList( new ArrayList<ProjectBuildingResult>( 512 ) );
 
-        List<InterimResult> interimResults = new ArrayList<>();
+        List<InterimResult> interimResults = synchronizedList( new ArrayList<InterimResult>( 512 ) );
 
         ReactorModelPool modelPool = new ReactorModelPool();
 
         InternalConfig config = new InternalConfig( request, modelPool,
                 useGlobalModelCache() ? getModelCache() : new ReactorModelCache() );
 
-        Map<String, MavenProject> projectIndex = new HashMap<>( 256 );
+        Map<String, MavenProject> projectIndex = new ConcurrentHashMap<>( 512 );
 
+        long phase1Start = currentTimeMillis();
+        Set<File> aggregatorFiles = Sets.newConcurrentHashSet();
         boolean noErrors =
-            build( results, interimResults, projectIndex, pomFiles, new LinkedHashSet<File>(), true, recursive,
-                   config );
+                build( results, interimResults, projectIndex, pomFiles, aggregatorFiles, true, recursive,
+                config );
+
+        if ( logger.isDebugEnabled() )
+        {
+            logger.debug( "Graph build phase 1 completed in " + ( currentTimeMillis() - phase1Start ) );
+        }
 
         populateReactorModelPool( modelPool, interimResults );
 
         ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
 
         try
         {
-            noErrors =
-                build( results, new ArrayList<MavenProject>(), projectIndex, interimResults, request,
-                       new HashMap<File, Boolean>(), config.session ) && noErrors;
+            long phase2Start = currentTimeMillis();
+
+            noErrors &= build( results, synchronizedList( new ArrayList<MavenProject>() ), projectIndex, interimResults,
+                    request, new ConcurrentHashMap<File, Boolean>(), config.session );
+            if ( logger.isDebugEnabled() )
+            {
+                logger.debug( "Graph build phase 2 completed in " + ( currentTimeMillis() - phase2Start ) );
 
 Review comment:
   Add 'ms'

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services