Re: Async File IO is not async?
Ian Griffiths <[email protected]> Sun, 6 Apr 2008 22:53:15 +0100
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <[email protected]> |
It's not clear that the fix you propose will necessarily help: that KB article identifies file extension as one of the things that *always* occurs synchronously. (Even if you've ticked all the boxes.) So given the example you've stated in that bug report, it might well be that you'll always need to do that on a separate thread if you need it to happen asynchronously. And conversely, for the situations where it is possible for async IO to occur, it might well already be just fine. The KB article you refer to says that FILE_FLAG_NO_BUFFERING can be used increase the chances that requests work asynchronously, but there are two things to bear in mind: 1) Disk IO is quite capable of happening asynchronously even if you don't specify that flag. 2) When Windows chooses to complete an async operation synchronously, it usually does so for a good reason: it can complete it instantly. (Although the file extension one does more seem to fit into the 'no good reason' camp... I did say 'usually', not 'always'.) A very common reason to do IO asynchronously in the first place is to avoid tying up a thread while you wait for the IO to complete. If the IO is able to complete instantly, then there's not often a benefit to going async. So arguably it'll do the best possible thing most of the time: it'll go async if the operation cannot complete instantly and async is an option; and it'll go sync if it can complete immediately. And unfortunately some cases won't go async no matter what you do. (At the end of the day, if one of the drivers you're depending on decides to make you wait there's not much you can do - whether an operation runs async in practice is 100% at the discretion of the drivers.) That's also a pretty old KB article. It talks about 16MB systems... I notice that it doesn't appear to apply to Windows 2003 or Windows Vista. --=20 Ian Griffiths -----Original Message----- From: Alex Ivanoff Sent: 05 April 2008 17:20 To: [email protected] Subject: Re: [DOTNET-CLR] Async File IO is not async? I finally got around to submitting a bug: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx? FeedbackID=3D337047. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This list is hosted by DevelopMentor=AE http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com