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 136308 - slow performance with output stream
Summary: slow performance with output stream
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P2 blocker (vote)
Assignee: Jiri Skrivanek
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2008-06-02 18:25 UTC by Vince Kraemer
Modified: 2008-12-22 10:55 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vince Kraemer 2008-06-02 18:25:04 UTC
I have code that does a bunch of file copy operations using FileUtil.copy(sourceFO.getInputStream(),
destFO.getOutputStream()). Using this code, the operation takes about a minute.  

I "know" that the FileObjects (sourceFO and destFO) are actual java.io.File objects.

When I transform the code to use "direct" file streams for the input and output, the copy operation takes about 12 seconds.

it seems like the streams returned by FileObject are causing the slowdown.  Since the calls to getInputStream and
getOutputStream are used in many places in the product, this may be a bottleneck for performance.
Comment 1 Vince Kraemer 2008-06-03 05:41:17 UTC
this issue is related to issue 136307.
Comment 2 Jiri Skrivanek 2008-06-03 10:11:19 UTC
FilterOutputStream created in FileObject.getOutputStream has to delegate write(byte b[], int off, int len) to underlying
FileOutputStream (if case FileObject is backed by File). Otherwise it is copied byte by byte.

http://hg.netbeans.org/core-main/rev/a0ed5cb309df
Comment 3 Vince Kraemer 2008-06-03 17:09:50 UTC
Your test allows for a 10x speed difference... which is pretty close to the level of difference that we were seeing in
practice, before the fix.

Maybe you should tighten up the test, to fail if the difference between the two strategies is 2x instead of 10x?
Comment 4 _ pcw 2008-06-04 00:43:48 UTC
Hi Jiri, would it make sense for this change ( http://hg.netbeans.org/main/rev/a0ed5cb309df ) to be incorporated into NB
6.1 patch 2?  Vince suggested that the performance improvement to the IDE on windows is noticable.
Comment 5 Quality Engineering 2008-06-04 04:16:06 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #236 build
Changeset: http://hg.netbeans.org/main/rev/a0ed5cb309df
User: Jiri Skrivanek <jskrivanek@netbeans.org>
Log: #136308 - fixed performance of FileUtil.copy. FilterOutputStream created in FileObject.getOutputStream has to delegate to underlying stream.
Comment 6 Vince Kraemer 2008-06-04 06:19:39 UTC
I took a second look at my test methodology and it had some weaknesses...  So I did the following test that I think is
"stronger".

I did an ide build (with the new code).
I restarted my windows box.
I opened a clock... to see the second hand..
I opened the TM to make sure the system was "done" with its start up busy-work.
I started the IDE and watched the second hand.
When the clock was covered... I wrote down the time it took to start... 35 second.

I then removed the fix. recompiled the ide and did it again... after a full restart.

The start-up time for the unpatched code was 45 seconds.

So.. the unpatched code took about 28% more time.

We should have someone else verify this result.
Comment 7 _ pcw 2008-06-04 06:39:58 UTC
I was thinking though - this change should have minimal impact on startup because it affects _writing_ of files, not
reading.  If it really has an impact on startup, that suggests that quite a bit of writing is being done during startup
and that just sounds wrong to me.  So either the performance improvement for startup is an illusion or some code is not
too bright.
Comment 8 Jiri Skrivanek 2008-06-04 08:34:22 UTC
> Your test allows for a 10x speed difference... which is pretty close to the level of difference that we were seeing in
> practice, before the fix.
> Maybe you should tighten up the test, to fail if the difference between the two strategies is 2x instead of 10x?

My observations are that a 10x speed difference is enough to catch regressions and also to have the test stable. I have
to encounter various configurations on which the test can be run. If you saw 2x difference in your code, please write a
new test in your module. Or attach a suggestion how to change my test case.

> Hi Jiri, would it make sense for this change to be incorporated into NB 6.1 patch 2?

I think it is a safe fix and it can go to the patch. It is up to QE to nominate it.
Comment 9 Lukas Hasik 2008-06-04 14:29:31 UTC
QE has no objection to add it to patch2 for NB61
Comment 10 Lukas Hasik 2008-06-04 14:30:54 UTC
Vince, could you verify this issue? It is requirement for integration to patch. Thank you.
Comment 11 Vince Kraemer 2008-06-04 20:50:00 UTC
verified.
Comment 12 Vince Kraemer 2008-06-04 22:11:17 UTC
I have to agree with PCW's comment about writing and start-up time.

It looks like the IDE would have to write 1.5 megs during start-up to account for the time difference that I was seeing.
 It must have been some other factor that accounts for the 10 seconds....
Comment 13 pgebauer 2008-06-09 17:51:07 UTC
The fix has been ported into the release61_fixes branch:

http://hg.netbeans.org/release61_fixes/73f77c5ea605
Comment 14 pgebauer 2008-07-08 16:10:49 UTC
The fix has been rolled back from the release61_fixes branch because of problem with its delivery via AUC.
Comment 15 Vince Kraemer 2008-07-08 17:09:54 UTC
Please provide more details about this... This bug is huge for Windows users.
Comment 16 pgebauer 2008-07-09 12:48:01 UTC
More details are available in the issue 139051