I have a situation where I want to perform a whole bunch of writes to a
file (a database) and when they are complete I want them committed to
disk (as much as is possible given that closing or fsyncing may not
necessarily flush all the buffers in the filesystem, disk controller
card, disk drive, etc.).
I am wondering whether, it is quicker to do these writes asynchronously
using say aiowrite64() or even lio_listio64() on AIX (I am not sure
whether there is a POSIX equivalent for that) or synchronously and
whether it makes sense to enable write-through (if it is possible).
I am figuring that that whichever method loads up the disk request queue
the most will prove to be the fastest because more requests in the queue
means
more for the disk scheduling algorithms in the disk device driver and
the SCSI TCQ queue to work with. Theoretically the worst performance
would be if you had write-through enabled and performed each write
synchronously. The disk request queue would never have more than
request in it. Enabling the write-back cache would enable writes to be
queued up (and possibly combined and merged although I do this in my own
code anyway). However I also figure that using the async writes also
does more or less the same thing although it obviously depends on the
amount of stuff you are writing, the number of writes (probably would be
between 10 - 20), and the size of the filesystem write buffers.
If the writes are small (probably wouldn't total more than a few KBs but
they are all at different offsets in the same huge file) then I am
guessing that it doesn't make sense for the OS to write-cache them so if
it is possible enable write-through behavior then I am guessing that
that would be better.
Does anyone have any experience in this area? The only way I know right
now is to try some different methods and find out...
Adrian