Bug 10628 - [resources] recursive deletion is slow
Summary: [resources] recursive deletion is slow
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P4 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-Resources-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
: 12119 32146 77245 81405 102727 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-03-02 09:53 EST by Genady Beryozkin CLA
Modified: 2009-08-18 16:20 EDT (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Genady Beryozkin CLA 2002-03-02 09:53:59 EST
I have a project of about 500 files residing on a network drive (samba).
The output folder is also there.
Too often, eclipse decides it should "scrub output folder". 
It takes too much time (sometimes more than few minues).
I can usually do the same operation (delete the output folder) within few seconds.

It usually happens after VCM operation, or changing the build path.
Comment 1 Philipe Mulet CLA 2002-03-04 06:09:40 EST
What build are you using ? What OS ?
Comment 2 Philipe Mulet CLA 2002-03-04 07:22:35 EST
Moving to Platform/Core, we simply use the IFile#delete implementation.
Comment 3 Genady Beryozkin CLA 2002-03-04 15:39:05 EST
It happens to me on windows NT and XP, with the last stable build
(14Feb).
Also my colleagues complain that the compilation is slow and that "scrubbing 
output folder" sometimes happens on normal file save (that should only trigger 
compilation).
I suspect that the file access is somehow not optimized. 

If you need, I can provide the exact samba server version and configuration
Comment 4 Genady Beryozkin CLA 2002-03-07 15:17:16 EST
Ok, we discovered some samba configuration deficiency and now it works faster, 
so the subject can probably change to simply "scrubbing output folder is slow".

Nevertheless, I think that deleting the whole directory is faster than deleting 
it file by file and this method should be used if possible.

Some additional info:
It seems that when "scrubbing output folder is printed", 
what really happens is removing all files from the output folder (as expected)
and also copying all non-source code resources to the output folder!
Comment 5 Genady Beryozkin CLA 2002-03-07 16:37:46 EST
I checked and found that deleting files in the command window (win2000) is 
about twice faster than doing it from java. Maybe you want to consider using 
a native function to delete a subtree. This would be only one (expensive) JNI 
call instead of hundrends/thousands.

P.S. This is my test code (tested on 2000 files)
		File dir = new File(dirName);
		File[] list = dir.listFiles();
		//Arrays.sort(list);
		long l1 = System.currentTimeMillis();
		for (int i = 0; i < list.length; i++) {
			File file = list[i];
			file.delete();
		}
		long l2 = System.currentTimeMillis();
		System.out.println("Time: " + (l2-l1));
Comment 6 Kent Johnson CLA 2002-03-26 11:08:34 EST
*** Bug 12119 has been marked as a duplicate of this bug. ***
Comment 7 Genady Beryozkin CLA 2002-03-27 08:54:19 EST
Just to describe the problem we had: the samba loglevel was set to 3.
Setting it to 1 definetely made things work faster.
Comment 8 DJ Houghton CLA 2002-06-05 13:10:39 EDT
Are you still seeing poor performance in the latest builds or has it improved?
Comment 9 Adalbert Homa CLA 2002-06-06 10:52:57 EDT
I tried it with the latest build, but no change. It will take Eclipse to scrub
the output 55 seconds, when Explorer will delete it in 15 seconds.
Comment 10 Genady Beryozkin CLA 2002-06-06 15:26:02 EDT
It is better, but still quite slow.
I suspect eclipse accesses many (very many) files
during "scrubbing" + full compilation.

Genady
Comment 11 Genady Beryozkin CLA 2002-09-27 14:53:36 EDT
I think this bug/feaure should be given higher priority.
Since the build on network drives is slow, it encourages people to 
do everything on the local drives which are not being backed up. This
practice will sooner or later lead to data loss.
Comment 12 DJ Houghton CLA 2002-09-27 15:14:33 EDT
There is current (high-priority) investigation on allowing users to change the 
structure of their project. Specifically one of the results will (hopefully) 
allow the bin directory to be (for instance) on a local drive and the rest of 
the project data on a server.
Comment 13 Genady Beryozkin CLA 2002-09-27 15:40:55 EDT
That's true, but in some cases it is not applicable. For example if a user 
wants to work on the same eclipse workspace on different computers, he has no 
choice. I don't say it's a high priority request, but I think it should be 
considered for 2.1.
Comment 14 Ludovic Claude CLA 2002-12-05 11:32:26 EST
I have the same issue with a Clearcase network drive. An alternative solution 
is to allow the use of a build directory that doesn't belong to the project 
space, so the build classes will be stored on the local drive, which is 
acceptable as they don't need backup.
Comment 15 Genady Beryozkin CLA 2002-12-05 17:37:59 EST
is this bug being investigated by the new performance team ?
Comment 16 Genady Beryozkin CLA 2003-06-19 15:05:26 EDT
I believe #32146 can be considered as a duplicate of this bug?
Comment 17 Genady Beryozkin CLA 2003-06-19 15:10:40 EDT
I meant bug #32146..

Here is another observation (I believe that at least some of the file access 
operations are unnecessary). Note that all these are OS operations, which 
means each of them requires java to do a native call, and then do a system 
call. Combination of these two is very slow.

I did a simple test of compiling (saving) one file, in a project that has only 
two files.
Now, I have used a file access monitor program, and it shows that compiling 
the file results in about ~10,000 OS-level file access operations:
Here is the list (remember - it is a result of compiling just one! file):

Number of accesses
----
     File name
     ---------
8526 C:\jdk-1.4.1\jre\lib\rt.jar
 416 C:\jdk-1.4.1\jre\lib\jsse.jar
 177 C:\jdk-1.4.1\jre\lib\ext\localedata.jar
  99 C:\jdk-1.4.1\jre\lib\sunrsasign.jar
  78 C:\jdk-1.4.1\jre\lib\ext\sunjce_provider.jar
  68 ...\workspace\rmi-test4\RemoteClass.java
  61 ...\workspace\.metadata\.plugins\org.eclipse.jdt.core\1291816999.index
  54 ...\workspace\rmi-test4\
  53 C:\jdk-1.4.1\jre\lib\jce.jar
  
46 ...\workspace\.metadata\.plugins\org.eclipse.jdt.core\1291816999.indexTempVA
  30 C:\
  24 ...\workspace\
  24 C:\eclipse\
  
20 ...\workspace\.metadata\.plugins\org.eclipse.core.resources\.history\.index.
log
  
20 ...\workspace\.metadata\.plugins\org.eclipse.core.resources\.history\.index
  18 ...\workspace\.metadata\.plugins\
  18 ...\workspace\.metadata\
  13 ...\workspace\rmi-test4\RemoteClass.class
  12 ...\workspace\rmi-test4
  10 ...\workspace\.metadata\.plugins\org.eclipse.core.resources\.history\5c
   9 ...\workspace\.metadata\.plugins\org.eclipse.jdt.core\
   
9 ..\workspace\.metadata\.plugins\org.eclipse.core.resources\.history\5c\00b43f
f40282001716c5bbf66f15be0b
   9 ...\workspace\.metadata\.plugins\org.eclipse.core.resources\.history\
   9 ...\workspace\.metadata\.plugins\org.eclipse.core.resources\
   6 C:\jdk-1.4.1\jre\lib\
   6 C:\jdk-1.4.1\jre\
   6 C:\jdk-1.4.1\
   6 ...\workspace\.metadata\.plugins\org.eclipse.jdt.core\savedIndexNames.txt
   6 ...\workspace\.metadata\.plugins\org.eclipse.core.resources\.history\5c\
   5 C:\jdk-1.4.1\jre\lib\charsets.jar
   3 C:\jdk-1.4.1\jre\lib\ext\ldapsec.jar
   3 C:\jdk-1.4.1\jre\lib\ext\dnsns.jar
   3 ...\workspace\rmi-test4\MyRemote.class
   3 ...\workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\rmi-
test4\org.eclipse.jdt.core
   2 C:\Recycler\NProtect\00011130.IND
   2 C:\Recycler\NProtect\00011126.LOG
   1 ...\workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\rmi-
test4\org.eclipse.jdt.core\state.dat

Genady 
Comment 18 John Arthorne CLA 2004-10-28 18:08:12 EDT
*** Bug 77245 has been marked as a duplicate of this bug. ***
Comment 19 Eric Rizzo CLA 2004-10-29 10:14:34 EDT
So what is the status of this issue? There has been no activity on this bug
entry for almost 18 months. I just created a new entry for general slowness of
deletion (not Samba-releated) and it was marked as a duplicate of this one.
That's fine, except that this one seems to be lost in the void.
Is there any real active research or dev going on here? It is a real pain to
have to go out of Eclipse every time I want to clean my large build directories.
Comment 20 Ed Burnette CLA 2004-10-29 10:28:28 EDT
Has anybody tried profiling this with YourKit or equivalent? I haven't, but 
just by watching the package explorer redraw and flash during a length 
deletion my theory is that Eclipse is trying to do some refreshes and builds 
and cvs re-decoration *during* the delete operation, which makes it take many 
times longer than it should.

I don't think this should be marked as an enhancement request. It's a 
performance bug. It'd be a good candidate for adding to the performance test 
suite too (not sure if that needs another bug entry or not).
Comment 21 Genady Beryozkin CLA 2004-10-29 17:22:15 EDT
I only solved this problem by working with local workspace.
The original problem of network workspaces still exists.

In another bug report/feature request I suggested renaming the output 
directory and deleting it in another thread. Maybe it should be reconsidered.
Comment 22 John Arthorne CLA 2004-12-16 10:41:38 EST
*** Bug 81405 has been marked as a duplicate of this bug. ***
Comment 23 John Arthorne CLA 2005-01-06 11:32:00 EST
*** Bug 32146 has been marked as a duplicate of this bug. ***
Comment 24 John Arthorne CLA 2005-02-24 12:32:53 EST
After investigation we decided not to pursue this for 3.1.  Most operating
systems don't seem to have a recursive deletion native.  Thus, writing our own
native to delete N files will still require N OS calls.  This would only
eliminate the cost of the JNI calls, which in the case of slow (network) file
systems, is not the principle bottleneck.

I'll mark this as "LATER" since it is a valid request, but it's just not clear
we can do much better than what java.io.File#delete provides us with today.
Comment 25 Eric Rizzo CLA 2005-02-25 12:14:50 EST
First let me say that I really appreciate the explanation of the status of this
bug - it is quite refreshing compared to the usual "Not going to address at this
time." that most bugzilla entries seem to get.
Having said that, I want to point out, in the context of the explanation, that
this is a problem even with local drives, not just with slow file systems.
My point is that it seems part of the justification for leaving this unaddressed
for now was because the bottleneck was the remote file system IO, not the
Java->native jump. I would argue that for local file systems the repeated
Java->native jumps IS a significant portion of the overall time. Thus there
would be a noticable benefit to writing a native recursive (or N-files) delete
function.
Comment 26 Eric Rizzo CLA 2005-02-25 12:20:57 EST
Just thought of another idea; although it is a little bit of a hack it might be
an  easier-to-implement interim solution.
I think that for most OSes, moving/renaming a directory is a small operation
compared to recursive delete. So Eclipse could, when a large directory tree is
being deleted, actually just relocate/rename it to a hidden "to-be-purged"
location in the workspace. An accompanying background job could clean stuff up
out of that "to-be-purged" location, in the background so it doesn't interfer
with the user's activity.
Comment 27 John Arthorne CLA 2005-02-25 12:33:50 EST
An interesting idea.  However, I think this will only help with the local disk
case.  java.io.File#renameTo is very fast when moving a directory to another
location on the same disk, but will almost certainly be slower than deletion if
it forces content to be copied to another disk or across a network.

My question for you: in the local disk case, now that deletion runs in a
background thread, how common is it that the deletion speed in Eclipse holds you
up?  Do you frequently delete very large amounts of data?  As a quick test, I
deleted a project (org.eclipse.jdt.ui), with 2000 files, 280 folders, for a
total of 14 MB.  Deletion from the resource navigator took just over 5 seconds.
 Are you running on a laptop or other machine with slow disk?
Comment 28 Genady Beryozkin CLA 2005-02-25 12:35:20 EST
I also think it's a good idea - see comment #21
(refers to bug 37417)

(In reply to comment #26)
> Just thought of another idea; although it is a little bit of a hack it might 
be
> an  easier-to-implement interim solution.
> I think that for most OSes, moving/renaming a directory is a small operation
> compared to recursive delete. So Eclipse could, when a large directory tree 
is
> being deleted, actually just relocate/rename it to a hidden "to-be-purged"
> location in the workspace. An accompanying background job could clean stuff 
up
> out of that "to-be-purged" location, in the background so it doesn't interfer
> with the user's activity.

Comment 29 Eric Rizzo CLA 2005-02-25 14:05:24 EST
(In reply to comment #27)
> My question for you: in the local disk case, now that deletion runs in a
> background thread, how common is it that the deletion speed in Eclipse holds you
> up?  Do you frequently delete very large amounts of data?  As a quick test, I
> deleted a project (org.eclipse.jdt.ui), with 2000 files, 280 folders, for a
> total of 14 MB.  Deletion from the resource navigator took just over 5 seconds.
>  Are you running on a laptop or other machine with slow disk?

Are you referring to 3.1 when you say that deletion runs in the background? I'm
not on 3.1 yet, but that might be enough to entice me...

As I said in Bug # 77245, I experimented with a folder that contains 2400 files
in 64 subdirectories, totaling 72MB. Windows File Explorer took on average 5-7
seconds to delete that folder. Eclipse Resource Navigator took more than 100
seconds. Not an otherwise slow disk (normal desktop, most likely a 7200 RPM IDE
drive).
Comment 30 John Arthorne CLA 2005-04-11 17:33:23 EDT
> Are you referring to 3.1 when you say that deletion runs in the background? I'm
> not on 3.1 yet, but that might be enough to entice me...

Yes, this is only in Eclipse 3.1 M5 or greater.
Comment 31 Adam Kiezun CLA 2005-04-25 17:59:03 EDT
On linux GTK and eclipse 3.1 M6 I see deletion of a folder with 2000 files *very
slow* and freezing the UI.
Comment 32 John Arthorne CLA 2005-04-26 09:56:25 EDT
Adam, how are you deleting the folder, from the Package explorer, Navigator, or
elsewhere?  Deletion is usually executed as a background job, so it should never
block the UI no matter how long it takes.  Some deletions in the Package
Explorer execute as refactorings, which may take longer and don't run in the
background.
Comment 33 Rafael Chaves CLA 2005-07-05 10:24:05 EDT
*** Bug 102727 has been marked as a duplicate of this bug. ***
Comment 34 John Arthorne CLA 2009-08-18 16:14:12 EDT
[LATER->WONTFIX] The "LATER" bugzilla resolution is being removed so reopening to mark as WONTFIX.
Comment 35 John Arthorne CLA 2009-08-18 16:20:16 EDT
[LATER->WONTFIX] The "LATER" bugzilla resolution is being removed so reopening to mark as WONTFIX.