N
nickdu
I'm curious how asynchronously writing to a file behaves, e.g. using
FileStream.BeginWrite()/EndWrite(). Is there a limit impossed on one
outstanding async IO?
I did a bit of testing comparing using synchronous writes v.s. using
asynchronous writes. I wasn't really looking for performance numbers but
more behavior. I expected the overall times of writing a certain amount of
data to a file to be the same, though I can see that doing this
asynchronously might be able to take advantage of combining multiple write
calls into a single write at some lower level.
What I was hoping to see is that the average duration of the
FileStream.BeginWrite() call to be significantly less than the average
duration of the FileStream.Write() call. This was not the case. The average
durations were roughly the same. Why? I can understand them being the same
if we're limited to one outstanding async IO. But I'm wondering if I might
be making some other mistake. Also, the max duration of the asynchronous
method was much bigger than the synchronous method, 3.6 seconds v.s. .6
seconds. The application both sit in a loop which executes 256K times
writing 4K buffers totaling 1GB.
Code snippets are both for both methods.
sync
====
Stream stm = File.Open(args[0], FileMode.Create,
FileAccess.ReadWrite, FileShare.None);
using(stm)
{
FileStream.BeginWrite()/EndWrite(). Is there a limit impossed on one
outstanding async IO?
I did a bit of testing comparing using synchronous writes v.s. using
asynchronous writes. I wasn't really looking for performance numbers but
more behavior. I expected the overall times of writing a certain amount of
data to a file to be the same, though I can see that doing this
asynchronously might be able to take advantage of combining multiple write
calls into a single write at some lower level.
What I was hoping to see is that the average duration of the
FileStream.BeginWrite() call to be significantly less than the average
duration of the FileStream.Write() call. This was not the case. The average
durations were roughly the same. Why? I can understand them being the same
if we're limited to one outstanding async IO. But I'm wondering if I might
be making some other mistake. Also, the max duration of the asynchronous
method was much bigger than the synchronous method, 3.6 seconds v.s. .6
seconds. The application both sit in a loop which executes 256K times
writing 4K buffers totaling 1GB.
Code snippets are both for both methods.
sync
====
Stream stm = File.Open(args[0], FileMode.Create,
FileAccess.ReadWrite, FileShare.None);
using(stm)
{