apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.62k stars 840 forks source link

Warmup Maven Embedder to improve first-project-creation UX #7590

Closed mbien closed 1 month ago

mbien commented 1 month ago

performance (EmbedderFactory):

cleanup:

the purple bits are com.google.inject.* code:

image

mbien commented 1 month ago

this is offtopic but this was unexpected: new Properties(other) is no copy constructor since it stores a reference to other! Since it is a Map, a collection copy-constructor rule matched for me. Reverted that change and fixed the rule.

mbien commented 1 month ago

I have to work on improving my stash management

sdedic commented 1 month ago

Hm, I guess originally the warmup was postponed to first project open so that it does not slow down startup of the application, but it could be possibly prior ergonomics was introduced which inhibits the whole module.

mbien commented 1 month ago

Hm, I guess originally the warmup was postponed to first project open so that it does not slow down startup of the application, but it could be possibly prior ergonomics was introduced which inhibits the whole module.

it is still the case. It just triggers the initialization a little bit earlier now. One wizard panel earlier to be exact.

When a project is already open, there should be no difference. With no project open there won't be any initialization still.

Technically I wouldn't call it warmup, since it is about early+concurrent vs late+blocking initialization and less about running things to throw them away again. If the initialization can run concurrently, it is often best to start it as soon you know it will be need.

one day I plan to revisit this again https://github.com/apache/netbeans/pull/5638 and check what is still needed and what can be optimized for new hardware/software realities.

quick way to debug the embedder initialization (I should have added proper logging there):

diff --git a/java/maven.embedder/src/org/netbeans/modules/maven/embedder/EmbedderFactory.java b/java/maven.embedder/src/org/netbeans/modules/maven/embedder/EmbedderFactory.java
index 752f59f..7482909 100644
--- a/java/maven.embedder/src/org/netbeans/modules/maven/embedder/EmbedderFactory.java
+++ b/java/maven.embedder/src/org/netbeans/modules/maven/embedder/EmbedderFactory.java
@@ -385,8 +385,10 @@
     }

     public static @NonNull MavenEmbedder getProjectEmbedder() {
+        System.out.println("<<<<<<<<<<<<<<<<get>>>>>>>>>>>>>>>>>>>");
         synchronized (PROJECT_LOCK) {
             if (project == null) {
+                System.out.println("<<<<<<<<<<<<<<<<init>>>>>>>>>>>>>>>>>>>");
                 try {
                     project = createProjectLikeEmbedder();
                 } catch (PlexusContainerException ex) {
@@ -394,6 +396,7 @@
                     throw new IllegalStateException(ex);
                 }
                 projectLoaded.set(true);
+                System.out.println("<<<<<<<<<<<<<<<<done>>>>>>>>>>>>>>>>>>>");
             }
             return project;
         }