I am trying to write a file as fast as I can through a buffered FileChannel similar to a BufferedOutputStream. I am wondering what is the optimum chunk of data I should use per write call to maximize bandwidth? I am on Ubuntu Linux.
closed as not a real question by Michael Hampton♦, Chopper3, HopelessN00b, Basil, Iain Sep 26 '12 at 16:48
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.
There is no such thing as a "one size fits all" perfect answer on a question like this. This sort of thing is impossible to predict.
It depends on the disk, controller, CPU, application, OS, other system load, kernel version, filesystem used and probably about a dozen other things I can't quickly remember right now.
Often bigger is better, but there usually is a point of diminishing returns.
Even if you figure this out for your development environment, you will have to do it all again for every other system on which the software needs to run.
Best to do some limited testing and then pick a "reasonable" value that performs "well enough" on the majority of intended target systems.