This is an automated email from the ASF dual-hosted git repository.

matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 3d20d2582f Invoke indexer in RepositoryUpdater grouped by mimepath of 
file
     new 24203679e9 Merge pull request #4324 from matthiasblaesing/js_indexing
3d20d2582f is described below

commit 3d20d2582f2a9c8abdcd18dad4f62e6091b5673b
Author: Matthias Bläsing <mblaes...@doppel-helix.eu>
AuthorDate: Fri Jul 1 22:13:11 2022 +0200

    Invoke indexer in RepositoryUpdater grouped by mimepath of file
    
    While analysing this it was found, that the GsfParserFactory#createParser
    returned null as the parser for snapshots. Looking deeper, showed, that
    the #createParser method was invoked with snapshots of differing mimetypes.
    
    This works, but is a violation of the contract in 
ParserFactory#createParser:
    
    > It is guaranteed that all snapshots in the collection will be
    > of the same mime type and it will be the mime type, which this factory
    > was registered for (ie. in MimeLookup)
    
    If the snapshots are inconsistent, parsing still works, but its performance
    suffers. To fix this the call to ParserManager#parse in RepositoryUpdater
    is split. The scanned sources are grouped by their mimepath and each group
    is individually passed.
    
    The observed improvements are:
    
    
    Indexing Variant 1 (tour-of-heroes)
    
    Before: ~125s
    After:  ~105s
    
    Indexing Variant 2 (tour-of-heros with Indexability Filter)
    
    Before: ~52s
    After:  ~38s
    
    The Indexability Filter blocks scanning for all paths with paths containing
    node_modules and where the indexer is in the list: js, angular, requirejs,
    knockoutjs, TLIndexer, tests.
---
 .../parsing/impl/indexing/RepositoryUpdater.java       | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git 
a/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java
 
b/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java
index 0d8f9cf3ab..308fa7c7d6 100644
--- 
a/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java
+++ 
b/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java
@@ -3250,7 +3250,23 @@ public final class RepositoryUpdater implements 
PathRegistryListener, PropertyCh
                             }
                         }
                     }
-                    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());
+                    }
                 } catch (final ParseException e) {
                     LOGGER.log(Level.WARNING, null, e);
                 } finally {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

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

Reply via email to