ntdll: make msync() call asynchronous in NtFlushVirtualMemory (try 3.5, alternate version)

Mathis Beer default_357-line at yahoo.de
Thu Jun 20 10:05:45 CDT 2013


Fixes bug 33146. Path of Exile's updater runs extremely slow (factor of 1000 compared to Windows) due to frequent FlushViewOfFile calls. FlushViewOfFile calls NtFlushVirtualMemory, which calls msync with MS_SYNC. FlushViewOfFile is the only function that calls NtFlushVirtualMemory in Wine, and is specified in the MSDN as asynchronous (http://msdn.microsoft.com/en-us/library/windows/desktop/aa366563%28v=vs.85%29.aspx ).

> The FlushViewOfFile function does not flush the file metadata, and it does not wait to return until the changes are flushed from the underlying hardware disk cache and physically written to disk.

As such, this patch changes msync to be called asynchronously.

I have searched through ten pages of Google results for msync, and have been unable to find a single documented instance of msync that did not also specify MS_ASYNC. I think it is safe to assume that on all (wine-relevant) platforms where msync is defined, MS_ASYNC is defined also. As such, this version of the patch dispenses with all the #ifdefs and just uses MS_ASYNC directly.

If anybody knows why MS_SYNC was originally #ifndef'd, correction would be appreciated.

---
 dlls/ntdll/virtual.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 121071f..3512c14 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -58,10 +58,6 @@
 WINE_DEFAULT_DEBUG_CHANNEL(virtual);
 WINE_DECLARE_DEBUG_CHANNEL(module);
 
-#ifndef MS_SYNC
-#define MS_SYNC 0
-#endif
-
 #ifndef MAP_NORESERVE
 #define MAP_NORESERVE 0
 #endif
@@ -2796,7 +2792,7 @@ NTSTATUS WINAPI NtFlushVirtualMemory( HANDLE process, LPCVOID *addr_ptr,
     {
         if (!*size_ptr) *size_ptr = view->size;
         *addr_ptr = addr;
-        if (msync( addr, *size_ptr, MS_SYNC )) status = STATUS_NOT_MAPPED_DATA;
+        if (msync( addr, *size_ptr, MS_ASYNC )) status = STATUS_NOT_MAPPED_DATA;
     }
     server_leave_uninterrupted_section( &csVirtual, &sigset );
     return status;
-- 
1.8.1.5

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-bug-33146-call-msync-with-MS_ASYNC.-Assume-msync.patch
Type: text/x-patch
Size: 1113 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20130620/7198a9ab/attachment-0001.bin>


More information about the wine-patches mailing list