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 203351

Summary: Slowness to run application after "Clean and Build Main Project"
Product: java Reporter: ceklock
Component: SourceAssignee: Jan Lahoda <jlahoda>
Status: RESOLVED WONTFIX    
Severity: normal CC: ceklock, dkonecny, pjiricka, tzezula
Priority: P3 Keywords: PERFORMANCE
Version: 7.1   
Hardware: PC   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: Profile
Profile after clean and build - 1st run of application
Profile after clean and build - 1st run of application - calltree
Profile after clean and build - 1st run of application - combined
Profile after clean and build - 1st run of application - html
Profile after clean and build - 1st run of application - html - combined
Profile after clean and build - 1st run of application - html - combined
Profile after clean and build - 2nd run of application
Profile after clean and build - 2nd run of application - calltree
Profile after clean and build - 2nd run of application - combined
Profile after clean and build - 2nd run of application - html - combined

Description ceklock 2011-10-08 08:20:26 UTC
After doing "Clean and Build" if I run a class I have to wait for a long time until the class finally starts to run. It seems like the classes are being compiled again. Compile on save is enabled. My project has more than 2000 classes.

Steps to reproduce:

- Open a big project
- Make sure compile on save is enabled
- Do "Clean and Build"
- Run some class
- Wait until it starts to run...
Comment 1 ceklock 2011-10-08 18:25:23 UTC
This only happens when "Compile on Save" is enabled. The HD keeps working for a long time, like it was recompiling everything (but hey, I have just done 'Clean and Build').
Comment 2 ceklock 2011-10-08 18:47:28 UTC
My current NetBeans version:

Product Version: NetBeans IDE 7.1 Beta (Build 201109252201)
Java: 1.6.0_27; Java HotSpot(TM) Client VM 20.2-b06
System: Windows 7 version 6.1 running on x86; Cp1252; en_BR (nb)

This also happens in NetBeans 7.0.1.
Comment 3 Tomas Hurka 2011-10-10 10:41:51 UTC
Can you please, use 'Profile Me Now' <http://wiki.netbeans.org/FitnessViaPartnership> and attach the snapshot to this bug.  thanks.
Comment 4 Tomas Zezula 2011-10-10 11:19:56 UTC
Please attache the nps(s) file.
http://wiki.netbeans.org/FitnessViaPartnership
Thanks
Comment 5 ceklock 2011-10-11 00:29:59 UTC
I will attach everything you need.
Comment 6 ceklock 2011-10-11 01:27:51 UTC
Created attachment 111819 [details]
Profile
Comment 7 Tomas Zezula 2011-10-11 13:22:39 UTC
There are two parts:
1st) The BAM.copyResources which copies the class files from cache to the build/classes which is OK if the run is done after clean. There was no build/classes/.netbeans_automatic_build file so the files were copied. But any other build should not do resource copying.
Can you verify that  after run the build/classes/.netbeans_automatic_build exists?

2nd) Index refresh as the index is marked as dirty, this can be caused by issue #202832.
Can you try it in some newer dev build?
Comment 8 ceklock 2011-10-12 13:26:00 UTC
Thanks for the reply. I will check everything because I am very interested about this issue. It happens all the time for me.
Comment 9 ceklock 2011-10-12 22:14:15 UTC
Now I am using the nightly build of NetBeans [ NetBeans IDE Dev (Build 201110110600) ].

At build/classes/ there are .netbeans_automatic_build and .netbeans_update_resources



Product Version: NetBeans IDE Dev (Build 201110110600)
Java: 1.6.0_27; Java HotSpot(TM) Client VM 20.2-b06
System: Windows 7 version 6.1 running on x86; Cp1252; en_BR (nb)
Comment 10 ceklock 2011-10-12 22:26:30 UTC
The nightly build is a little faster considering this issue, but is not as fast as it should be. At the first time that I run an application after 'clean and build' it is much slower than the second time (at the second time is almost instantly without all the HD usage).


Product Version: NetBeans IDE Dev (Build 201110110600)
Java: 1.6.0_27; Java HotSpot(TM) Client VM 20.2-b06
System: Windows 7 version 6.1 running on x86; Cp1252; en_BR (nb)
Comment 11 ceklock 2011-10-12 23:08:41 UTC
Created attachment 111956 [details]
Profile after clean and build - 1st run of application
Comment 12 ceklock 2011-10-12 23:09:25 UTC
Created attachment 111957 [details]
Profile after clean and build - 1st run of application - calltree
Comment 13 ceklock 2011-10-12 23:10:06 UTC
Created attachment 111958 [details]
Profile after clean and build - 1st run of application - combined
Comment 14 ceklock 2011-10-12 23:11:36 UTC
Created attachment 111959 [details]
Profile after clean and build - 1st run of application - html
Comment 15 ceklock 2011-10-12 23:18:52 UTC
Created attachment 111960 [details]
Profile after clean and build - 1st run of application - html - combined
Comment 16 ceklock 2011-10-12 23:19:57 UTC
Created attachment 111961 [details]
Profile after clean and build - 1st run of application - html - combined
Comment 17 ceklock 2011-10-12 23:25:01 UTC
Created attachment 111962 [details]
Profile after clean and build - 2nd run of application
Comment 18 ceklock 2011-10-12 23:25:45 UTC
Created attachment 111963 [details]
Profile after clean and build - 2nd run of application - calltree
Comment 19 ceklock 2011-10-12 23:26:26 UTC
Created attachment 111964 [details]
Profile after clean and build - 2nd run of application - combined
Comment 20 ceklock 2011-10-12 23:28:51 UTC
Created attachment 111965 [details]
Profile after clean and build - 2nd run of application - html - combined
Comment 21 ceklock 2011-10-12 23:30:34 UTC
Attached more snapshots above: 1st run (slow) and 2nd run (fast).
Comment 22 Jan Lahoda 2011-10-13 00:04:24 UTC
Sorry, but you should not be using Clean&Build with compile on save enabled, except when you actually need the distribution jar. The first run after build will clean all previous compilation results, and will use whatever IDE has in its caches. This is to prevent possible problems with incompatible compilations and other stale data. What is the reason to use Clean&Build?
Comment 23 ceklock 2011-10-13 00:59:22 UTC
Really? :O

Main reason is to update resources, because I can't use the 'Build' feature when compile on save is enabled.
Comment 24 Jan Lahoda 2011-10-13 01:10:27 UTC
You should not need to do anything to get resources updated (unless your build script contains a custom filtering for them, or creates new resources, neither of which is supported by compile on save andthe CoS should be disabled in such a case). 7.0 and 7.1 differ slightly in this respect: 7.0 placed the "src" folder on the classpath, which effectively made all resources in the source folder accessible through ClassLoader.getResource. In 7.1 (done about a month ago, IIRC), the resources should be copied automatically to the build/classes and updated each time the resource in the src folder is updated. I did a quick test, and this seems to work. What exactly is your usecase? Thanks.
Comment 25 ceklock 2011-10-13 02:18:15 UTC
Take a look at this:
http://netbeans.org/bugzilla/show_bug.cgi?id=203618
Comment 26 Tomas Zezula 2011-10-13 06:28:05 UTC
In my environment no copying is done as well.
Can you add the status or the build/classes/.netbeans_automatic_build file (does it exists after you do run)? is the next run slow again?
Thanks
Comment 27 ceklock 2011-10-13 10:58:48 UTC
Did Clean&Build again, at first run it was slow, second was fast.

.netbeans_automatic_build and .netbeans_update_resources were created at build/classes/ after the first run. The two files are empty.


Product Version: NetBeans IDE Dev (Build 201110110600)
Java: 1.6.0_27; Java HotSpot(TM) Client VM 20.2-b06
System: Windows 7 version 6.1 running on x86; Cp1252; en_BR (nb)
Comment 28 ceklock 2011-10-13 11:08:26 UTC
* With 'first run' I mean the first run of my application. First run of the application was slow, second fast. 

.netbeans_automatic_build and .netbeans_update_resources were created only after the first run.
Comment 29 jmborer 2011-10-13 11:23:42 UTC
It might be related to the "Compile on Save" feature which is enabled by default. I think this option is useless with Maven projects. Turning it off improves the launch speed of processes.
Comment 30 Tomas Zezula 2011-10-13 11:34:12 UTC
The first build is slow as the CoS needs to synchronize the caches with the build folder.
After the synchronization the .netbeans_automatic_build and .netbeans_update_resources are created.
The IDE knows that the build/classes is in sync with cache (all other changes done in the IDE) are tracked by incremental sync and the other runs are fast. When you delete the .netbeans_automatic_build or the .netbeans_update_resources (for example by clean) the full sync is done again.
Comment 31 ceklock 2011-10-16 21:24:43 UTC
> You should not need to do anything to get resources updated.

I checked this now and you are right. If I create a file and try to access it using class.getResource() I don't have the problems I had times ago.

The following code works ok for a newly created file called 'resource.txt' (FileIO is an utility class that I created).

        URL resource = ResourceAccessTest.class.getResource("resource.txt");
        FileIO fileIO = new FileIO(resource.toURI());
        String loadedString = fileIO.loadString();
        System.out.println("loaded string: ");
        System.out.println(loadedString);

So, the resources are being copied properly.



Product Version: NetBeans IDE Dev (Build 201110110600)
Java: 1.6.0_27; Java HotSpot(TM) Client VM 20.2-b06
System: Windows 7 version 6.1 running on x86; Cp1252; en_BR (nb)
Comment 32 ceklock 2011-10-16 22:10:06 UTC
> The first build is slow as the CoS needs to synchronize the caches with the
> build folder.
> After the synchronization the .netbeans_automatic_build and
> .netbeans_update_resources are created.
> The IDE knows that the build/classes is in sync with cache (all other changes
> done in the IDE) are tracked by incremental sync and the other runs are fast.
> When you delete the .netbeans_automatic_build or the .netbeans_update_resources
> (for example by clean) the full sync is done again.


The current issue that is annoying me is that when I do "CVS Update" I get this same slowness when I run something...
Comment 33 ceklock 2011-10-16 22:14:51 UTC
* after I do "CVS Update"
Comment 34 ceklock 2011-10-22 02:49:22 UTC
Steps to reproduce: 

- Open a big project with many packages and classes;
- Make sure "Compile on Save" is enabled;
- Do "CVS Update" or "Clean and Build";
- Run a class.
Comment 36 ceklock 2012-11-06 23:16:23 UTC
Bug still present in NetBeans 7.2.1. 


The steps to reproduce are the same:

- Open a big project (this project has 8.547 files, 1.247 folders);
- Make sure compile on save is enabled;
- Do "Clean and Build";
- Run some class;
- Wait until it starts to run... (why do I have to wait so much time if I just compiled everything with Clean and Build??)


Product Version: NetBeans IDE 7.2.1 (Build 201210100934)
Java: 1.7.0_09; Java HotSpot(TM) Server VM 23.5-b02
System: Windows 7 version 6.1 running on x86; Cp1252; en_BR (nb)
Comment 37 Jan Lahoda 2012-11-07 17:39:38 UTC
(In reply to comment #36)
> The steps to reproduce are the same:
> 
> - Open a big project (this project has 8.547 files, 1.247 folders);
> - Make sure compile on save is enabled;
> - Do "Clean and Build";
> - Run some class;
> - Wait until it starts to run... (why do I have to wait so much time if I just
> compiled everything with Clean and Build??)

Sorry, but I do not think this is going to be fixed, unless there is a compelling reason to combine regular running of Clean and Build and compile on save. Currently, it is expected that Clean&Build is run only rarely to produce final project artifacts (i.e. jar).