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 128047 - Excessive calls to File.isDirectory() in InstalledFileLocaterImpl.java
Summary: Excessive calls to File.isDirectory() in InstalledFileLocaterImpl.java
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Pavel Flaska
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2008-02-21 17:19 UTC by Pavel Flaska
Modified: 2008-12-22 11:48 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
InstalledFileLocatorImpl.makeFile() -- method calls (874 bytes, text/plain)
2008-02-21 17:37 UTC, Pavel Flaska
Details
Old callers - full stacks (18.65 KB, text/plain)
2008-02-21 17:53 UTC, Pavel Flaska
Details
Suggested patch (1.45 KB, text/plain)
2008-02-21 18:06 UTC, Pavel Flaska
Details
Results when patch applied (14.03 KB, text/plain)
2008-02-21 18:07 UTC, Pavel Flaska
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Flaska 2008-02-21 17:19:47 UTC
InstallFileLocaterImpl.java: Too many calls to FileUtil.normalizeFile() even when results are never used.
Comment 1 Pavel Flaska 2008-02-21 17:37:04 UTC
Created attachment 56999 [details]
InstalledFileLocatorImpl.makeFile() -- method calls
Comment 2 Pavel Flaska 2008-02-21 17:53:22 UTC
Created attachment 57001 [details]
Old callers - full stacks
Comment 3 Pavel Flaska 2008-02-21 18:06:04 UTC
Created attachment 57003 [details]
Suggested patch
Comment 4 Pavel Flaska 2008-02-21 18:07:06 UTC
Created attachment 57004 [details]
Results when patch applied
Comment 5 Pavel Flaska 2008-02-21 18:21:05 UTC
File.isDirectory() invocations from InstalledFileLocatorImpl.java summary:
trunk: 7467 invocations
patch: 2069 invocations

Environment: custom build, jdk1.6.0_04.
Steps:
1. start IDE with existing user-dir,
2. wait a minute,
3. shutdown IDE.

user-dir was created, but no activity was done in IDE.
Comment 6 Jaroslav Tulach 2008-02-21 22:35:53 UTC
Imho it should be enough to convert 
dirs[i] = FileUtil.normalizeFile(dirs[i])
and then just skip any further normalizations. As far as I understand the concept of normalizeFile, this should still 
behave as expected and it would decrease the number from 2000 to some small constant ~ 10.

Jesse and Nejedlaku, can we do such change?
Comment 7 Jesse Glick 2008-02-22 00:44:25 UTC
Yes, I think that would be an easy and safe optimization.
Comment 8 Petr Nejedly 2008-02-22 07:56:25 UTC
I would think so too, normalize doesn't follow symlinks.
But make sure ".." is documented forbidden then, you might be changing the behavior slightly otherwise.
Comment 9 Jesse Glick 2008-02-22 14:51:06 UTC
Exactly, '../' sequences should be forbidden. I hope no one was using them to begin with.
Comment 10 Pavel Flaska 2008-02-22 15:05:36 UTC
Fixed in trunk, changeset aa562c6e76b5
Comment 11 Jaroslav Tulach 2008-02-22 21:54:39 UTC
Perfect. Now something similar for JarClassLoader, please ;-)
Comment 12 Jaroslav Tulach 2008-02-23 19:37:23 UTC
One additional improvement imho, is to make sure this test will not be unnoticeably affected by changes in Java VM. 
Because it might happen that the calls change and the isDirectory will no longer be 3rd element on the stack. In such 
case we shall update the test, otherwise it stops measure anything. 

One way to do it, is to verify that the counter is incremented at least few times, eg. > 0.