Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Optimal Buffer Size?

800308Mar 9 2009 — edited Mar 13 2009
Folks,

In [this thread|http://forums.sun.com/thread.jspa?messageID=10635136#10635136] I posted code to "copy" a file via a socket... Yeah not very original, I know... but I started experimenting with the buffer sizes between 4k and 132k trying to make it run as fast as possible.

All I magaged to prove was that your milage may vary, lots ... and therefore I conclude that my testing strategy must be fundamentally flawed... a "dirty" test bed, and far too few executions.

My question is: Is there a rule-of-thumb, or an accepted technique to workout how big to make read/write buffers for optimal performance? I don't mean just sockets, but all places where we read and write buffers full of bytes: like reading and writing local files, or whatever.

Groping around testing every possibility you can think of (every time you hit such a situation) is tedious, to say the least.

Cheers all. Keith.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 10 2009
Added on Mar 9 2009
10 comments
573 views