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 117288 - JsfJavaDataLoader is very slow
Summary: JsfJavaDataLoader is very slow
Status: VERIFIED FIXED
Alias: None
Product: obsolete
Classification: Unclassified
Component: visualweb (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: _ potingwu
URL:
Keywords: PERFORMANCE
Depends on:
Blocks: 114195
  Show dependency tree
 
Reported: 2007-10-01 12:09 UTC by Petr Nejedly
Modified: 2007-10-04 16:55 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
netbeans profiler snapshot (27.54 KB, application/octet-stream)
2007-10-02 09:21 UTC, Quy Nguyen
Details
nb profiler snapshot (jsfloader in java project) (31.84 KB, application/octet-stream)
2007-10-02 21:44 UTC, Quy Nguyen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Nejedly 2007-10-01 12:09:52 UTC
JsfJavaDataLoader does file hierarchy traversal and project.xml's parsing for each recognized file.
It means that during folder opening, the project file is parsed many times, contributing heavily to the UI
responsiveness of the IDE. Folder traversal is also nontrivial contribution, when done many times.

If you need to recognize project type this way during file recognition, you could cache the result of the check based on
the first parent folder, so it will be done only once for given opened folder.
Comment 1 _ potingwu 2007-10-01 17:03:19 UTC
Visual Web already cached the 'project folder'. There is no reparsing of the project.xml file. I.e., For every project,
there is only one 'single' parse for all the files inside an individual project!

Are you sure you still seeing this parsing many times?

Please see org.netbeans.modules.visualweb.project.jsf.api.JsfProjectUtils.isJsfProjectFile(FileObject), the first step
it does is to looking at the cache isJsfProjectDir. And this has been filed/fixed/verified by issue#111029.


*** This issue has been marked as a duplicate of 111029 ***
Comment 2 Petr Nejedly 2007-10-01 22:43:28 UTC
You're right, I see the parsing only once.
But the parent folder traversal and project.xml localization is there many many times and these are in turn more
expensive than the parsing. Also, you could probably replace the full XML parse with simple string matching, as is done
in similar case for the Mobility's J2MEDataLoader
Comment 3 _ potingwu 2007-10-01 23:00:04 UTC
Quy, could you please evaluate this performance? I don't think the parent folder traversal is expensive unless there are
hundreds of them, but looks like it's not. I also don't think one single xml parsing per project is expensive neither,
scanning some special string looks dangerous to me!

If we really need to do something here, then please reassign back to me. Thanks!
Comment 4 Quy Nguyen 2007-10-02 09:21:05 UTC
Created attachment 49960 [details]
netbeans profiler snapshot
Comment 5 Quy Nguyen 2007-10-02 09:31:26 UTC
I've attached an NB profiler snapshot showing the execution times of JsfJavaDataLoader.findPrimaryFile() during the
opening of a visual web project and several of its source folders.  It does appear that the
JsfProjectUtils.isJsfProjectFile() method takes some time (through the FileObject.getFileObject() method) as well as
JsfProjectUtils.getJspForJava().  The caching for these methods could probably be more aggressive, so re-assigning to
Po-Ting for a possible fix.
Comment 6 _ potingwu 2007-10-02 17:09:28 UTC
Quy, I don't have resource to looks at the .nps file (is it from JProfiler?). Could you please attach some data in pure
text form? Thanks!
Comment 7 Petr Nejedly 2007-10-02 17:59:50 UTC
That's the NetBeans profiler snapshot.
Just open in the IDE using either File->Open or Profiler->Open snapshot.
 
Comment 8 Quy Nguyen 2007-10-02 21:42:40 UTC
Here is another snapshot showing the opening of a package node in a java project containing 100 java source files.  Most
of the execution time (~90%) is in JsfProjectUtils.isJsfProjectFile().
Comment 9 Quy Nguyen 2007-10-02 21:44:03 UTC
Created attachment 50040 [details]
nb profiler snapshot (jsfloader in java project)
Comment 10 _ potingwu 2007-10-03 21:10:19 UTC
Quy, I have done one partial fix for method isJsfProjectFile(), it now caches all directories inside a project instead
of just the root directory. This will eliminate the parent folder traversal time. It should make both the getFileObject
and getParent calls to the minimum. Could you please verify it?

/cvs/visualweb/project/jsf/src/org/netbeans/modules/visualweb/project/jsf/api/JsfProjectUtils.java,v  <-- 
JsfProjectUtils.java
new revision: 1.49; previous revision: 1.48
Comment 11 Quy Nguyen 2007-10-03 22:00:59 UTC
The performance issue related to folder traversal appears to have been resolved.  The calls to
FileObject.getFileObject() and FileObject.getParent() changed as follows on a java package with 100 source files:

FileObject.getFileObject() (# of calls):
Before: 402 calls
After: 6 calls

FileObject.getParent() (# of calls):
Before: 300 calls
After: 102 calls
Comment 12 _ potingwu 2007-10-03 22:38:37 UTC
Replace the full XML and Property parse with simple string matching to improve performance. Quy, could you please verify
the performance again? Thanks!

/cvs/visualweb/project/jsf/src/org/netbeans/modules/visualweb/project/jsf/api/JsfProjectUtils.java,v  <-- 
JsfProjectUtils.java
new revision: 1.50; previous revision: 1.49
Comment 13 Quy Nguyen 2007-10-03 22:54:47 UTC
The parsing change seems to have improved the performance.  I think the issue submitter should verify that the issue
blocked by this one is resolved by these changes.
Comment 14 Petr Nejedly 2007-10-04 16:55:47 UTC
Much better now under the profiler. Still incurs some penalty, but that's the data systems problem in general.