matthiasblaesing commented on code in PR #4324:
URL: https://github.com/apache/netbeans/pull/4324#discussion_r916201811


##########
ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java:
##########
@@ -3250,7 +3250,23 @@ public void run(ResultIterator resultIterator) throws 
Exception {
                             }
                         }
                     }
-                    ParserManager.parse(sources.keySet(), new T());
+
+                    // Performance of ParserManager#parse suffers if the 
sources
+                    // are of mixed mimetype. ParserManager will then generate
+                    // snapshots with mixed mimetypes, which violates the
+                    // ParserFactory contract and leads to slower code paths.
+                    //
+                    // To work around this the sources are passed to the
+                    // ParserManager grouped by their mimetype
+
+                    Map<String,List<Source>> sourcesByMimeType = sources
+                            .keySet()
+                            .stream()
+                            
.collect(Collectors.groupingBy(s->s.getMimeType()));
+
+                    for(List<Source> l: sourcesByMimeType.values()) {
+                        ParserManager.parse(l, new T());
+                    }

Review Comment:
   In the end parsing and indexing is expensive and we won't get rid of it. 
This is more a bugfix, that doubles as a performance improvement. I'll continue 
to stare at profiles of JS parsing, but outside this.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to