apache / netbeans

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

Suspicious indexing with dev build from master (NB 21) #6921

Closed mbien closed 9 months ago

mbien commented 9 months ago

Was testing something else when I noticed that NB is indexing JDK zips for almost 40s, repeating the test on NB 20 worked fine so it must be a recent change.

edit: bisection showed that #6329 seems to be the issue, checking out the commit before 192bb526a9f535485905998674460c1aaafb9b20 restores the behavior of NB 20. Clean revert isn't possible anymore which makes this a bit more tricky.

reproduce:

  1. start with fresh config, don't import config
  2. create maven project, open java file, jump into println method
  3. check log after a while (or observe the background process indicator)
INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Indexing of: jar:file:/usr/lib/jvm/default/lib/src.zip!/java.base/ took: 36,619 ms (New or modified files: 3,037, Deleted files: 0) [Adding listeners took: 0 ms]
INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Complete indexing of 1 source roots took: 36,619 ms (New or modified files: 3,037, Deleted files: 0) [Adding listeners took: 0 ms]
INFO [org.netbeans.ui.indexing]: Indexing finished, indexing took 39,407 ms.

image

this is repeatable after restart, index update is only slightly faster:

INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Refresh of custom indexer ([text/x-java]) for root: jar:file:/usr/lib/jvm/default/lib/src.zip!/java.base/ forced by: org.netbeans.modules.java.source.indexing.JavaCustomIndexer$Factory@31aa22
INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Indexing of: jar:file:/usr/lib/jvm/default/lib/src.zip!/java.base/ took: 25,286 ms (New or modified files: 0, Deleted files: 0) [Adding listeners took: 0 ms]
INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Complete indexing of 1 source roots took: 25,286 ms (New or modified files: 0, Deleted files: 0) [Adding listeners took: 0 ms]
INFO [org.netbeans.ui.indexing]: Indexing finished, indexing took 25,313 ms.

(NB 20 doesn't scan that zip after restarts and/or first start)

I did also notice other log lines:

INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Indexing of: /home/mbien/NetBeansProjects/netbeans/nbbuild/netbeans/webcommon/jsstubs/dom-stubs.zip took: 11,013 ms (New or modified files: 1,044, Deleted files: 0) [Adding listeners took: 0 ms]
INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Indexing of: /home/mbien/NetBeansProjects/netbeans/nbbuild/netbeans/webcommon/jsstubs/core-stubs.zip took: 398 ms (New or modified files: 106, Deleted files: 0) [Adding listeners took: 0 ms]

I am not quite sure why NB is trying to scan those zips.

matthiasblaesing commented 9 months ago

The dom-stubs.zip and core-stubs.zip files come from the javascript support. Both zips contain JS method stubs, that encode common JS API (the built-in functions and the DOM API). For JS there is a classpath provider, that provides these and they are indexed once when they are first used. They provide the base for JS code completion. I hope that clears this. I suspect at some point JS files were being indexed and thus the CP for these is initialized.

mbien commented 9 months ago

@matthiasblaesing thanks for elaborating, this clears up why NB is indexing content of those particular zip files, but not quite why NB thinks it is important to index them while the user is looking at a hello world maven project. E.g I would understand it I would copy them into a project or maybe open the folder in the favorites view - but I didn't do that.

The multi-file PR must trigger scanning in some way by adding to the paths NB is interested in (or something equivalent).