Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » J2EE Interest »

Re: Performance of BufferedOutputStream.write()

Jean-Christian Imbeault

2005-01-16


This is in response to a problem I posted a while back. We've finally
managed to get some testing code into production to see what the
differences are between:

1- streaming content directly to the client from the 'presentation' layer
2- having a business object pass a file's content in memory back to the
presentation and then streamed
3- buffering vs. unbuffered IO

The results were quite surprising. Basically there was no real difference
in terms of performance. At most a possible statistically significant
difference of about 5% when reading and streaming directly from the
presentation layer.

Of course I don't include the performance benefits incurred by having less
objects to GC. Considering that a full GC cycle takes less than 1 second
on our machine it was deemed to be important but not much.

I'll be posting a new thread asking for help with this issue again now
that I have real-life data to help me ask the right questions.

Thanks,

Jc

Frans Verhoef wrote:

>> The reason I ask is that I don't want to fix it (i.e. implement
>> your solution) if all I will get is a 5% performance improvement.
>> I'm in need of a >2x performance benefit :(
>
>
> I did a little test myself, transferring a file (about 300kb) from one
harddisk to another using both methods. Method1 first loading the whole
file, before streaming it to the new location, and method2 streams to
the new location while streaming in from the file.
>
> Method2 finishes the transfer consistently in 12-14 micro seconds. In
about half the times method 1 also finishes in 12-14 micro seconds.
However, the other times it can take as long as 90 microseconds.
>
> Probably the reason behind it is that due to the big amounts of data you
keep on loading into the virtual machine, the garbage collector needs
more time to clear the heap.
>
> Maybe you could try to make a little test servlet to test the two
different methods in a servlet environment.
>
> Hope its helpful.
>
> Frans

===========================================================================
To unsubscribe, send email to listserv@(protected)
of the message "signoff J2EE-INTEREST". For general help, send email to
listserv@(protected)".
©2008 junlu.com - Jax Systems, LLC, U.S.A.