-6

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.

chrisapotek
  • 585
  • 2
  • 6
  • 17
  • what protocols are involved? – Chopper3 Sep 26 '12 at 16:02
  • Protocols? This is disk I/O on Linux Ubuntu. – chrisapotek Sep 26 '12 at 16:06
  • * sigh * and they're attached to the machine via....? – Chopper3 Sep 26 '12 at 16:10
  • sorry, as you can see I am not a hardware guy hehehe... man, that regular socket they have nowadays on the motherboard... i forgot the name, ISO? I remember in the distant past they had SCSI but that is gone, right? – chrisapotek Sep 26 '12 at 16:16
  • Ok, well you just made sure this question is unanswerable sorry, we can't give you even a wild guess without even that basic information. – Chopper3 Sep 26 '12 at 16:17
  • It would help more if you guys tell me how do I find out what controller my box is using for the Hard Drive... – chrisapotek Sep 26 '12 at 16:48
  • Ask your sysadmin. – Basil Sep 26 '12 at 16:53
  • Thanks to Tonny. For the rest you should work on your attitude towards hardware noobs. I am not ashamed of saying and don't know that stuff, i guess that's why I am here, right? – chrisapotek Sep 26 '12 at 17:02
  • But you shouldn't be, this isn't a site for learners - that's what we're trying to say. If you went to a site that said it was SPECIFICALLY for professional aircraft pilots you wouldn't expect to be treated with a great deal of respect if you asked what a wing was would you? Well unlike stackoverflow and superuser this site ISN'T for teaching learners, it's for people who are professional sysadmins - as it states right at the top of the FAQ. So we lay out our 'attitudes' from day one, you chose to ignore them. You shouldn't be ashamed no, this just isn't the site for you is all. – Chopper3 Sep 26 '12 at 17:09

1 Answers1

6

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.
Trial and error is, for any given system, the only way to say for sure.

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.

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
Tonny
  • 6,332
  • 1
  • 18
  • 31
  • Thanks, Tonny. If you were to guess or pick a value without doing much research for your Linux system, what would that value be? Just your personal feeling about this value. A rough guess :) – chrisapotek Sep 26 '12 at 16:05
  • I would use 64K and 128K and see which one works best. On a raid or SSD ALWAYS use a multiple of the stripe-size (raid) or native block-size (SSD). Smaller really can kill performance. – Tonny Sep 26 '12 at 16:09
  • I am on a disk hard drive here... no SSD... for now... :) – chrisapotek Sep 26 '12 at 16:11