Optimal Buffer and Destination Byte Array Size for java.io.BufferedInputStream Reads (for a slow disk)
A continuation of micro benchmarking
Earlier in the week I ran some micro-benchmarks against my new very performant Intel X25M solid state drive. Today, for 'kicks', I ran the same benchmarks with the same data against a 5,400 RPM external USB-attached 3.5" hard disk drive. Wow, what a difference that makes!
Destination Byte Array Size vs. KBps (for 16 different Buffer Sizes + the default)

(Larger Image)
Detailed description of the graph (same as previous post):
- x-axis: The destination byte array size used in individual read method calls as defined by payloadSize in this snippet:
byte[] payload = new byte[payloadSize]; int readIn = is.read(payload); - y-axis: The speed in Kilobytes per second for a complete build up, file opening and reading, and the algorithm's computation.
- series (individual lines): Individual BufferedInputStream buffer size's as set with buffSize during class initialization.
FileInputStream fis = FileInputStream(file); InputStream is = new BufferedInputStream(fis, buffSize)
For a slower disk, the conclusions are different only in the specific sizes:
One aspect of this entire performance question that I have not measured is the CPU load for these different operations. Hmmm...maybe for a new post...