The third, and final, part of this 3 part series[Part -1, Part - 2] covers I/O Completions and Memory Management techniques. I will go through the different ways to handle I/O completions with some recommendations and optimizations introduced in Vista and later releases of Windows. I will also cover tradeoffs associated with designing single and multiple process applications. Finally, I will go through memory fragmentation, heap management, and provide a list of the new and expanded NUMA topology APIs.
Some common I/O issues: It is recommended to use asynchronous I/O to avoid switching threads and to maximize performance. Asynchronous I/O is more complex because it needs to determine which of the many outstanding I/Os completed. Those I/Os may be to different handles, mixed file and network I/O, etc. There are many different ways to handle I/O completion, not all of which are suitable for high performance (e.g. WaitForMultipleObjects, I/O Completion Routines). For highest performance, use I/O Completion Ports. Prior to Vista, scanning the pending overlapped structures was necessary to achieve the highest performance, but the improvements in Vista have made that technique obsolete. However, it should be noted that an asynchronous write can block when extending a file and there is no asynchronous OpenFile.