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 2022/01/16 21:22:14 UTC

[GitHub] [maven] famod opened a new pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

famod opened a new pull request #662:
URL: https://github.com/apache/maven/pull/662


   
   As discussed in the ticket, including groupId if needed.
   
   I also changed the prefix from `mvn-builder-` to `mvn-builder_` to better see where the artifactId starts (which often contains dashes).
   
   ---
   
   Following this checklist to help us incorporate your
   contribution quickly and easily:
   
    - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) filed
          for the change (usually before you start working on it).  Trivial changes like typos do not
          require a JIRA issue. Your pull request should address just this issue, without
          pulling in other changes.
    - [x] Each commit in the pull request should have a meaningful subject line and body.
    - [x] Format the pull request title like `[MNG-XXX] SUMMARY`, where you replace `MNG-XXX`
          and `SUMMARY` with the appropriate JIRA issue. Best practice is to use the JIRA issue
          title in the pull request title and in the first line of the commit message.
    - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [x] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will
          be performed on your pull request automatically.
    - [x] You have run the [Core IT][core-its] successfully.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
    - [x] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   [core-its]: https://maven.apache.org/core-its/core-it-suite/
   


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] michael-o commented on a change in pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
michael-o commented on a change in pull request #662:
URL: https://github.com/apache/maven/pull/662#discussion_r785507270



##########
File path: maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
##########
@@ -183,19 +196,26 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
     private Callable<ProjectSegment> createBuildCallable( final MavenSession rootSession,
                                                           final ProjectSegment projectBuild,
                                                           final ReactorContext reactorContext,
-                                                          final TaskSegment taskSegment, final ThreadOutputMuxer muxer )
+                                                          final TaskSegment taskSegment,
+                                                          final ThreadOutputMuxer muxer,
+                                                          final Set<String> duplicateArtifactIds )
     {
         return () ->
         {
             final Thread currentThread = Thread.currentThread();
             final String originalThreadName = currentThread.getName();
-            currentThread.setName( "mvn-builder-" + projectBuild.getProject().getId() );
+            final MavenProject project = projectBuild.getProject();
+
+            final String threadNameSuffix = duplicateArtifactIds.contains( project.getArtifactId() )
+                    ? project.getGroupId() + ":" + project.getArtifactId()
+                    : project.getArtifactId();
+            currentThread.setName( "mvn-builder_" + threadNameSuffix );

Review comment:
       Please revert, we can discuss this when this is really going to be a problem.




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] michael-o commented on a change in pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
michael-o commented on a change in pull request #662:
URL: https://github.com/apache/maven/pull/662#discussion_r785498345



##########
File path: maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
##########
@@ -129,14 +132,23 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
                                                        Map<MavenProject, ProjectSegment> projectBuildList,
                                                        ThreadOutputMuxer muxer )
     {
+        // gather artifactIds which are not unique so that the respective thread names can be extended with the groupId
+        Set<String> duplicateArtifactIds = projectBuildList.keySet().stream()

Review comment:
       1. I wonder how much calculation overhead this poses to the execution
   2. This won't work for 3.8.x because of Java 8 features.




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] famod commented on pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
famod commented on pull request #662:
URL: https://github.com/apache/maven/pull/662#issuecomment-1014865869


   @michael-o on it!


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] michael-o commented on pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
michael-o commented on pull request #662:
URL: https://github.com/apache/maven/pull/662#issuecomment-1014737634


   Let me test that and we are likely good to merge.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] famod commented on a change in pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
famod commented on a change in pull request #662:
URL: https://github.com/apache/maven/pull/662#discussion_r785506735



##########
File path: maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
##########
@@ -183,19 +196,26 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
     private Callable<ProjectSegment> createBuildCallable( final MavenSession rootSession,
                                                           final ProjectSegment projectBuild,
                                                           final ReactorContext reactorContext,
-                                                          final TaskSegment taskSegment, final ThreadOutputMuxer muxer )
+                                                          final TaskSegment taskSegment,
+                                                          final ThreadOutputMuxer muxer,
+                                                          final Set<String> duplicateArtifactIds )
     {
         return () ->
         {
             final Thread currentThread = Thread.currentThread();
             final String originalThreadName = currentThread.getName();
-            currentThread.setName( "mvn-builder-" + projectBuild.getProject().getId() );
+            final MavenProject project = projectBuild.getProject();
+
+            final String threadNameSuffix = duplicateArtifactIds.contains( project.getArtifactId() )
+                    ? project.getGroupId() + ":" + project.getArtifactId()
+                    : project.getArtifactId();
+            currentThread.setName( "mvn-builder_" + threadNameSuffix );

Review comment:
       I did it just for readability. It's not a big thing, so I can change it back.




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] famod commented on a change in pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
famod commented on a change in pull request #662:
URL: https://github.com/apache/maven/pull/662#discussion_r785508393



##########
File path: maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
##########
@@ -129,14 +132,23 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
                                                        Map<MavenProject, ProjectSegment> projectBuildList,
                                                        ThreadOutputMuxer muxer )
     {
+        // gather artifactIds which are not unique so that the respective thread names can be extended with the groupId
+        Set<String> duplicateArtifactIds = projectBuildList.keySet().stream()

Review comment:
       > 1. I wonder how much calculation overhead this poses to the execution
   
   Even for hunderts of projects this should be alright, IMO, but I haven't done any measurements.
   We could also switch over to something like: https://stackoverflow.com/a/30741906/9529981
   
   > 2. This won't work for 3.8.x because of Java 8 features.
   
   Right. I can create a Java 8 compatible backport PR if you want.




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] famod commented on pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
famod commented on pull request #662:
URL: https://github.com/apache/maven/pull/662#issuecomment-1014887392


   Here we go: #663


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] gnodet commented on a change in pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
gnodet commented on a change in pull request #662:
URL: https://github.com/apache/maven/pull/662#discussion_r786154294



##########
File path: maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
##########
@@ -129,14 +132,23 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
                                                        Map<MavenProject, ProjectSegment> projectBuildList,
                                                        ThreadOutputMuxer muxer )
     {
+        // gather artifactIds which are not unique so that the respective thread names can be extended with the groupId
+        Set<String> duplicateArtifactIds = projectBuildList.keySet().stream()

Review comment:
       > > 1. I wonder how much calculation overhead this poses to the execution
   
   This is done only once afaik, and is limited by the number of projects so the computational cost remains low.  I don't see any potential problem here.
    
   > > 2. This won't work for 3.8.x because of Java 8 features.
   > 
   > Right. I can create a Java 8 compatible backport PR if you want.
   
   Please do.




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] michael-o commented on a change in pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
michael-o commented on a change in pull request #662:
URL: https://github.com/apache/maven/pull/662#discussion_r785497688



##########
File path: maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
##########
@@ -183,19 +196,26 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
     private Callable<ProjectSegment> createBuildCallable( final MavenSession rootSession,
                                                           final ProjectSegment projectBuild,
                                                           final ReactorContext reactorContext,
-                                                          final TaskSegment taskSegment, final ThreadOutputMuxer muxer )
+                                                          final TaskSegment taskSegment,
+                                                          final ThreadOutputMuxer muxer,
+                                                          final Set<String> duplicateArtifactIds )
     {
         return () ->
         {
             final Thread currentThread = Thread.currentThread();
             final String originalThreadName = currentThread.getName();
-            currentThread.setName( "mvn-builder-" + projectBuild.getProject().getId() );
+            final MavenProject project = projectBuild.getProject();
+
+            final String threadNameSuffix = duplicateArtifactIds.contains( project.getArtifactId() )
+                    ? project.getGroupId() + ":" + project.getArtifactId()
+                    : project.getArtifactId();
+            currentThread.setName( "mvn-builder_" + threadNameSuffix );

Review comment:
       Do you expect this to be a problem? This adds inconsistency to the rest of our thread names. I would only address it if is a problem only.




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] famod commented on a change in pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
famod commented on a change in pull request #662:
URL: https://github.com/apache/maven/pull/662#discussion_r785496490



##########
File path: maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
##########
@@ -129,14 +132,23 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
                                                        Map<MavenProject, ProjectSegment> projectBuildList,
                                                        ThreadOutputMuxer muxer )
     {
+        // gather artifactIds which are not unique so that the respective thread names can be extended with the groupId
+        Set<String> duplicateArtifactIds = projectBuildList.keySet().stream()
+                .map( MavenProject::getArtifactId )
+                .collect( Collectors.groupingBy( Function.identity(), Collectors.counting() ) )

Review comment:
       We could also stop here, usage in `createBuildCallable()` would then be something like:
   ```java
   final String threadNameSuffix = artifactIdFrequency.get( project.getArtifactId() ) > 1
           //...
   ```




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] michael-o commented on pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
michael-o commented on pull request #662:
URL: https://github.com/apache/maven/pull/662#issuecomment-1014865049


   @famod Waiting for a PR against 3.8.x.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven] asfgit closed pull request #662: [MNG-7381] Shorten thread name to artifactId, conditionally with groupId

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #662:
URL: https://github.com/apache/maven/pull/662


   


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org