Optimal Buffer Size?
800308Mar 9 2009 — edited Mar 13 2009Folks,
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.