This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 141514 - IDE is unusable during Task Scanning
Summary: IDE is unusable during Task Scanning
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Action Items (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords: PERFORMANCE
: 140312 145815 (view as bug list)
Depends on: 146890 146891
Blocks:
  Show dependency tree
 
Reported: 2008-07-24 11:26 UTC by Jan Horvath
Modified: 2008-10-06 17:14 UTC (History)
15 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
threaddump (22.98 KB, text/plain)
2008-07-24 11:27 UTC, Jan Horvath
Details
threaddump (27.39 KB, text/plain)
2008-07-24 11:27 UTC, Jan Horvath
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Horvath 2008-07-24 11:26:13 UTC
Product Version: NetBeans IDE Dev (Build 080724)
Java: 1.5.0_13; Java HotSpot(TM) Client VM 1.5.0_13-119
System: Mac OS X version 10.5.4 running on i386; MacRoman; en_EN (nb)

This week the becomes almost unusable for me because of Task Scanning after startup. 
Scanning runs about 5 minutes after startup on my MacBook with Core2Duo and takes 
90 - 165% CPU according to top. There are 8 projects opened in the IDE - 3x J2SE, 3x Web
2x NB module.

attaching two  thread dumps
Comment 1 Jan Horvath 2008-07-24 11:27:14 UTC
Created attachment 65510 [details]
threaddump
Comment 2 Jan Horvath 2008-07-24 11:27:57 UTC
Created attachment 65511 [details]
threaddump
Comment 3 Stanislav Aubrecht 2008-07-24 11:52:55 UTC
maybe the java task scanner should wait till classpath scanning is finished at startup - reassigning to java team for
evaluation
Comment 4 Jan Becicka 2008-07-24 12:10:29 UTC
This is still the same issue.
1. Java Source module does not do any IO/CPU intensive things in parallel with classpath scanning.
2. This is JPAVerfication Task and the other J2EE tasks. Cannot recall their name.
3. Task list should not start anything in paralel with classpath scanning, no matter if it is related to java or not.
Classpath scanning is IO intensive operation and starting another IO intensive operation in parallel with scanning is
simply wrong. Simply don't do it :)

We would like to help you with it. Ask for help.
Comment 5 Stanislav Aubrecht 2008-07-24 12:20:33 UTC
> We would like to help you with it. Ask for help.
please help:)
Comment 6 Stanislav Aubrecht 2008-07-24 12:44:10 UTC
*** Issue 140312 has been marked as a duplicate of this issue. ***
Comment 7 Jan Becicka 2008-07-24 14:57:24 UTC
Well. We have SourceUtils.isScanInProgress () and waitScanFinished() ...
   
Comment 8 Stanislav Aubrecht 2008-07-24 15:17:29 UTC
thanks for the tip. is there any way to find out that class path scanning is about start or has just started?
another problem is that i don't want task list impl to depend on java...
Comment 9 Jan Becicka 2008-07-24 15:35:59 UTC
isScanInProgress (), waitScanFinished() and runWhenScanFinished are the only methods we have.
Comment 10 Tomas Pavek 2008-07-24 17:14:57 UTC
The scanning done by task list significantly affects post-startup (or post project open) performance even if done 
after the CP scan. Already without task list scanning this was one of the biggest performance issue in the IDE. This 
is something we should not make worse - which is happening now when the task list is shown in the default IDE setup. 
Can you please turn off the addional scans in the task list's default setup (leaving on users to turn them possibly 
on)? This is a very minimum we can do to keep the performance acceptable. (Assuming the java errors/warnings for which 
this unadvised change was mainly done can be obtained from java infrastructure without additional scan.)
Comment 11 Jan Becicka 2008-07-24 17:52:57 UTC
Yes. Java errors/warnings are available "for free".
As I already mentioned, the bad tasks comes (IMO) from JPAVerificationTask and EJBVerificationSomething.
Comment 12 Stanislav Aubrecht 2008-07-25 12:01:54 UTC
i've turned all task providers off by default except for java tasks as tpavek suggested. so there won't be any task list
originated io during the initial class path scan: 973ce6c0aaf2


however i still think that the task list should pause itself when class path scanning is running (or any other io heavy
activity). but since there's no api for this it'll have to wait till the next release
Comment 13 Jesse Glick 2008-07-25 18:39:52 UTC
Your change caused module tests to fail, so I rolled it back (#ce110b8d2259).
Comment 14 Stanislav Aubrecht 2008-07-26 09:25:05 UTC
fixed again (with fixed test)

659c12fd7360
615b48465c93
Comment 15 Torbjorn Norbye 2008-08-26 22:17:50 UTC
I don't think this solution is okay for non-Java projects.

Here's what I wrote on a mailing list:

Hmmm.... Can we at least make this project type sensitive?

If you're using the Ruby distribution, and you open a Ruby project, you should get to see the Ruby errors in your
project.  Furthermore, for Ruby we show hints as well, not just errors as is the case for Java. I think this is a really
useful improvement (and I always build the contrib/javahints module as well to get similar behavior for Java).

Without this, you have to go and open each and every file in your project to see where your semantic errors are. Other
IDEs such as Eclipse manage to do this. I think we should consider building a cache into the tasklist such that it can
come back up at startup immediately populated with results. A refresh button can be used to cause it to flush the cache
and regenerate everything. I don't think anybody will be confused if they exit the IDE, delete/add/edit files, restart
the IDE and they see somewhat stale results in the tasklist - they'll just hit Refresh.

It's great that our IDE automatically detects edits outside the IDE and reloads the current editor etc., but for
something like the tasklist, I don't think anybody will fault us for caching results. Certainly doing lots of additional
disk processing at startup is not something people will prefer.   And I think a cache is vastly superior to just
disabling everything except Java errors.

-- Tor
Comment 16 Petr Jiricka 2008-08-28 11:19:31 UTC
Any comments on Tor's suggestion? The current state when tasklist is opened by default but does not show anything is not
acceptable. For now, let's reenable the scanning of errors (at least for GSF - that's the most important area), and then
deal with performance issues, if any. Either the way Tor suggests, or some other way.

Another solution is to hide the tasklist by default (as was the case in 6.1), but I'd rather not do that.
Comment 17 Petr Pisl 2008-08-28 12:41:10 UTC
I agree with Tor and Petr. From PHP point of view, it doesn't have sense to open task list by default, if it doesn't
show anything from PHP files by default.
Comment 18 Petr Pisl 2008-08-28 12:41:19 UTC
I agree with Tor and Petr. From PHP point of view, it doesn't have sense to open task list by default, if it doesn't
show anything from PHP files by default.
Comment 19 Stanislav Aubrecht 2008-09-04 08:27:56 UTC
*** Issue 145815 has been marked as a duplicate of this issue. ***
Comment 20 Tomas Pavek 2008-09-04 10:00:38 UTC
> For now, let's reenable the scanning of errors (at least for GSF - that's the most important area),
> and then deal with performance issues, if any.

If any? This issue was reported because having all the scanning running made the IDE unusable. Now you suggest to 
return back to that state? I don't agree with this. First solve the performance issues, then reenable the scanning of 
errors.

Speaking about GSF only, I understand the current state is not good for GSF-based projects from usability point of 
view. If you can make the GSF scanning not affect java-based projects, then fine. E.g. by making it project type 
sensitive, as Tor suggested.
Comment 21 Torbjorn Norbye 2008-09-04 17:37:56 UTC
I have checked in a fix to GSF's task scanner, such that when the task-scanning scope is project wide, it will only scan
gsf-enabled projects.  In particular, this means that if you open a plain Java project, it will not scan for relevant
source files.  (Of course, that means that any Groovy errors or hints will not be scanned, since as I understand it,
Groovy uses plain Java projects).

If you however have a Rails project, a Scala project, a Java Web project, or a PHP project, the scanner will kick in as
usual.

Also, if you have set the scope to Current File, it will check with GSF and if the file is a GSF file, you will get
scanning errors. Thus, even if you have JavaScript file in a Java project, if you open it, you can see errors (for
scope=current file). But it won't look for JavaScript files at the project scanning level.

This was changeset 6b4081992fa8.

Can the GSF task provider be re-enabled now? Or is there something else I should do?

Also, Martin - is there a quick and fast way for me to check if a Java project is "Groovy" enabled? Does it add some
project level property I can check? It would be nice to also include GSF scanning for these projects if there's
something fast and simple we can check in the case of Java projects.
Comment 22 Stanislav Aubrecht 2008-09-04 18:29:18 UTC
i'm working on a fix that will pause task scanning when classpath scanning is in progress. so all providers will be
enabled by default then.
Comment 23 martin_adamek 2008-09-05 10:56:37 UTC
> Also, Martin - is there a quick and fast way for me to check if a Java project is "Groovy" enabled? Does it add some
> project level property I can check? It would be nice to also include GSF scanning for these projects if there's
> something fast and simple we can check in the case of Java projects.

Only friendly used org.netbeans.modules.groovy.support.spi.GroovyFeature.isGroovyEnabled() which is used to enable Groovy refactoring only for Groovy-
enabled projects (Grails and Java SE with Groovy enabled in properties)
Comment 24 Stanislav Aubrecht 2008-09-08 14:29:59 UTC
i've created a short wiki page describing my proposal for 'project type specific task scanning':
http://wiki.netbeans.org/TaskListScanningExtension

pls let me know if that solution is good enough for everybody. as there are some API changes needed, i'm turning this
issue to fast-track API review.

note: pausing the task list when classpath scanning is in progress is still part of this fix.
Comment 25 Torbjorn Norbye 2008-09-08 17:27:11 UTC
I wonder if it isn't best to just rewrite all the Task Providers to instead be project sensitive.

It's hard to write declaratively whether a task provider should be enabled for a project or not. If we use project
lookup instead, then a project can dynamically determine whether it gets task scanning.

This is roughly what I did in the GSF task provider on Friday: When the setScope() method is called on the TaskProvider,
it checks the projects in the scope, and decides whether they apply. This means the decision of whether a task provider
applies to a project type is made on the task provider side, rather than on the projects side. That seems like the right
place to have the logic (and as I understand it is also what you were proposing in the wiki, except you made it
declaratively rather than computed by code).

The advantage we have by using lookup, however, is that this should be more flexible. For example, take Groovy. A
standard Java project (which according to our XML files should disable everything except the Java task provider) can
also be used for Groovy. In that case, the Groovy integration can augment the project lookup with additional classpath
information (for GSF), which will make GSF's task provider kick in because it suddenly finds additional project context.

In short, I think we should make all Task Providers enabled by default, but we should visit each and every one of them
and MAKE SURE they perform very minimal computations immediately to decide if they apply. In most cases, this means
checking if the projects in the lookup are of the set of projects the task provider cares about. In case the scope is
file scope, it means looking up the project containing the file and making the same decision. But in some cases, a file
scope can be used to see if just the filetype matters. This means that for example in a Java project, which normally
doesn't have the GSF task provider running, if you open a JavaScript file, you -still- get tasks provided because GSF
knows that it should run the GSF task provider on JavaScript files that are explicitly opened, no matter what the
project type is!

I think this gives us more flexibility than something based on static project type registration, and I don't think it
has a performance downside if we perform the "appliesTo" logic to all the task filters. 
Comment 26 Petr Jiricka 2008-09-08 18:24:35 UTC
Some more comments on the proposal:
- I think the enabled state of the ToDo provider should be the same in all projects. If this provider is fast enough,
then it should be enabled all the time. If not, then it should be disabled all the time.
- The Default filter should be language-neutral. E.g. when I use the IDE for PHP and C++ development, then a Default
with only Java scanning enabled in not the sensible default. Tor's proposal addresses this - all providers are on by
default, so they are treated symmetrically. 
- Tor's proposal also has advantages for Maven project - I can imagine that the Maven project could expose the
information on whether it has the webapp archetype, and the GSF provider could enable/disable scanning of JavaScript,
CSS, JSP etc. based on this info.

And one question:
> note: pausing the task list when classpath scanning is in progress is still part of this fix.

Will this apply also to GSF scanning? I think the situation is analogous to Java classpath scanning, so should the
tasklist be also paused when GSF scanning is in progress?
Comment 27 Jesse Glick 2008-09-08 22:26:04 UTC
I would extend pjiricka's concern about Maven projects to apply also to freeform and automatic projects. For these cases
it does not make much sense for the project to declare a particular filter. It would be better for scanners to decide
whether or not they apply to the project based on their inspection of the project's services, e.g. source roots and
their classpaths, or existence of a web module.
Comment 28 Stanislav Aubrecht 2008-09-09 08:32:14 UTC
well, there are no API changes required if we want to let the task providers to decide whether they apply to project(s)
in current scope or not. the project already are in scope's lookup so it's up to the implementors of task providers to
add some project sensitive logic.

re 'pausing task scanning while classpath scanning is in progress' - it applies to all Java classpath scanning only and
as there's no public API for it there'll be some hack from task list impl in ide cluster to java cluster. if there's an
API or hook to gfs scanner, i can plug in there too.
Comment 29 Petr Jiricka 2008-09-09 08:45:47 UTC
One more thing - any comments on Tor's suggestion to cache results across IDE sessions, so the results come up very
quickly after startup? Is this desirable/feasible?
Comment 30 Stanislav Aubrecht 2008-09-09 08:56:40 UTC
> One more thing - any comments on Tor's suggestion to cache results across IDE sessions, so the results come up very
quickly after startup? Is this desirable/feasible?

it is feasible but not in 6.5 time frame
Comment 31 Stanislav Aubrecht 2008-09-10 13:19:50 UTC
after a bit of testing (http://wiki.netbeans.org/TaskListScanningExtension) it seems safe to turn all task providers on
by default except for EJB and JPA task scanners which slow the task list down the most. they are both file-based
scanners and basically compile each Java source file again when enabled (they use runUserActionTask()). when those two
scanners are turned off the task list is reasonably fast.
Comment 32 Petr Jiricka 2008-09-11 08:54:46 UTC
Thanks many times for the investigation, Stando. I filed separate issues to track the slow speed for EJB and JPA: issue
146890 for EJB, and issue 146891 for JPA.
Comment 33 Torbjorn Norbye 2008-09-11 15:35:06 UTC
So does this all mean that we can get the GSF task provider enabled by default again, or is there anything else I can do?
Comment 34 Stanislav Aubrecht 2008-09-11 15:40:21 UTC
> So does this all mean that we can get the GSF task provider enabled by default again, or is there anything else I can do?
yes GSF task provider will be on by default (unless there are strong objections from somebody else). i'm just waiting
for java team guys to implement a hook into classpath scanning so that i can close this issue.
Comment 35 Stanislav Aubrecht 2008-09-23 11:29:29 UTC
fixed - the task list will pause all file access when java classpath scanning is in progress. java, gsf and todo task
providers are turned on by default.


ebeac74c369d
Comment 36 Quality Engineering 2008-09-25 06:32:38 UTC
Integrated into 'main-golden', will be available in build *200809250201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ebeac74c369d
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #141514 - pause task list when classpath scanning is in progress, turn java, todo and gsf task providers on by default
Comment 37 Oleg Khokhlov 2008-10-06 14:28:43 UTC
Hi Jan,

could you please verify this bug because performance team is really interested in fix results.
Comment 38 Jan Horvath 2008-10-06 17:14:48 UTC
verified. The performance in the recent daily builds was improved.