mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 17:24:12 +08:00
mdbx-windows: use PrefetchVirtualMemory().
This commit is contained in:
parent
fd0c92927a
commit
9ddfa4f9c8
@ -667,6 +667,7 @@ MDBX_GetFileInformationByHandleEx mdbx_GetFileInformationByHandleEx;
|
|||||||
MDBX_GetVolumeInformationByHandleW mdbx_GetVolumeInformationByHandleW;
|
MDBX_GetVolumeInformationByHandleW mdbx_GetVolumeInformationByHandleW;
|
||||||
MDBX_GetFinalPathNameByHandleW mdbx_GetFinalPathNameByHandleW;
|
MDBX_GetFinalPathNameByHandleW mdbx_GetFinalPathNameByHandleW;
|
||||||
MDBX_SetFileInformationByHandle mdbx_SetFileInformationByHandle;
|
MDBX_SetFileInformationByHandle mdbx_SetFileInformationByHandle;
|
||||||
|
MDBX_PrefetchVirtualMemory mdbx_PrefetchVirtualMemory;
|
||||||
MDBX_NtFsControlFile mdbx_NtFsControlFile;
|
MDBX_NtFsControlFile mdbx_NtFsControlFile;
|
||||||
|
|
||||||
static void mdbx_winnt_import(void) {
|
static void mdbx_winnt_import(void) {
|
||||||
@ -691,21 +692,14 @@ static void mdbx_winnt_import(void) {
|
|||||||
mdbx_srwlock_ReleaseExclusive = stub_srwlock_ReleaseExclusive;
|
mdbx_srwlock_ReleaseExclusive = stub_srwlock_ReleaseExclusive;
|
||||||
}
|
}
|
||||||
|
|
||||||
mdbx_GetFileInformationByHandleEx =
|
#define GET_KERNEL32_PROC(ENTRY) \
|
||||||
(MDBX_GetFileInformationByHandleEx)GetProcAddress(
|
mdbx_##ENTRY = (MDBX_##ENTRY)GetProcAddress(hKernel32dll, #ENTRY)
|
||||||
hKernel32dll, "GetFileInformationByHandleEx");
|
|
||||||
|
|
||||||
mdbx_GetVolumeInformationByHandleW =
|
GET_KERNEL32_PROC(GetFileInformationByHandleEx);
|
||||||
(MDBX_GetVolumeInformationByHandleW)GetProcAddress(
|
GET_KERNEL32_PROC(GetVolumeInformationByHandleW);
|
||||||
hKernel32dll, "GetVolumeInformationByHandleW");
|
GET_KERNEL32_PROC(GetFinalPathNameByHandleW);
|
||||||
|
GET_KERNEL32_PROC(SetFileInformationByHandle);
|
||||||
mdbx_GetFinalPathNameByHandleW =
|
GET_KERNEL32_PROC(PrefetchVirtualMemory);
|
||||||
(MDBX_GetFinalPathNameByHandleW)GetProcAddress(
|
|
||||||
hKernel32dll, "GetFinalPathNameByHandleW");
|
|
||||||
|
|
||||||
mdbx_SetFileInformationByHandle =
|
|
||||||
(MDBX_SetFileInformationByHandle)GetProcAddress(
|
|
||||||
hKernel32dll, "SetFileInformationByHandle");
|
|
||||||
|
|
||||||
const HINSTANCE hNtdll = GetModuleHandleA("ntdll.dll");
|
const HINSTANCE hNtdll = GetModuleHandleA("ntdll.dll");
|
||||||
mdbx_NtFsControlFile =
|
mdbx_NtFsControlFile =
|
||||||
|
@ -5819,6 +5819,14 @@ static int __cold mdbx_env_map(MDBX_env *env, const int is_exclusive,
|
|||||||
if (unlikely(rc != 0))
|
if (unlikely(rc != 0))
|
||||||
return errno;
|
return errno;
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
if (mdbx_PrefetchVirtualMemory) {
|
||||||
|
WIN32_MEMORY_RANGE_ENTRY hint;
|
||||||
|
hint.VirtualAddress = env->me_map;
|
||||||
|
hint.NumberOfBytes = usedsize;
|
||||||
|
(void)mdbx_PrefetchVirtualMemory(GetCurrentProcess(), 1, &hint, 0);
|
||||||
|
}
|
||||||
|
#endif /* Windows */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_VALGRIND
|
#ifdef USE_VALGRIND
|
||||||
|
15
src/osal.h
15
src/osal.h
@ -732,7 +732,6 @@ typedef BOOL(WINAPI *MDBX_GetVolumeInformationByHandleW)(
|
|||||||
_Out_opt_ LPDWORD lpMaximumComponentLength,
|
_Out_opt_ LPDWORD lpMaximumComponentLength,
|
||||||
_Out_opt_ LPDWORD lpFileSystemFlags,
|
_Out_opt_ LPDWORD lpFileSystemFlags,
|
||||||
_Out_opt_ LPWSTR lpFileSystemNameBuffer, _In_ DWORD nFileSystemNameSize);
|
_Out_opt_ LPWSTR lpFileSystemNameBuffer, _In_ DWORD nFileSystemNameSize);
|
||||||
|
|
||||||
extern MDBX_GetVolumeInformationByHandleW mdbx_GetVolumeInformationByHandleW;
|
extern MDBX_GetVolumeInformationByHandleW mdbx_GetVolumeInformationByHandleW;
|
||||||
|
|
||||||
typedef DWORD(WINAPI *MDBX_GetFinalPathNameByHandleW)(_In_ HANDLE hFile,
|
typedef DWORD(WINAPI *MDBX_GetFinalPathNameByHandleW)(_In_ HANDLE hFile,
|
||||||
@ -744,7 +743,6 @@ extern MDBX_GetFinalPathNameByHandleW mdbx_GetFinalPathNameByHandleW;
|
|||||||
typedef BOOL(WINAPI *MDBX_SetFileInformationByHandle)(
|
typedef BOOL(WINAPI *MDBX_SetFileInformationByHandle)(
|
||||||
_In_ HANDLE hFile, _In_ FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
|
_In_ HANDLE hFile, _In_ FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
|
||||||
_Out_ LPVOID lpFileInformation, _In_ DWORD dwBufferSize);
|
_Out_ LPVOID lpFileInformation, _In_ DWORD dwBufferSize);
|
||||||
|
|
||||||
extern MDBX_SetFileInformationByHandle mdbx_SetFileInformationByHandle;
|
extern MDBX_SetFileInformationByHandle mdbx_SetFileInformationByHandle;
|
||||||
|
|
||||||
typedef NTSTATUS(NTAPI *MDBX_NtFsControlFile)(
|
typedef NTSTATUS(NTAPI *MDBX_NtFsControlFile)(
|
||||||
@ -753,9 +751,20 @@ typedef NTSTATUS(NTAPI *MDBX_NtFsControlFile)(
|
|||||||
OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG FsControlCode,
|
OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG FsControlCode,
|
||||||
IN OUT PVOID InputBuffer, IN ULONG InputBufferLength,
|
IN OUT PVOID InputBuffer, IN ULONG InputBufferLength,
|
||||||
OUT OPTIONAL PVOID OutputBuffer, IN ULONG OutputBufferLength);
|
OUT OPTIONAL PVOID OutputBuffer, IN ULONG OutputBufferLength);
|
||||||
|
|
||||||
extern MDBX_NtFsControlFile mdbx_NtFsControlFile;
|
extern MDBX_NtFsControlFile mdbx_NtFsControlFile;
|
||||||
|
|
||||||
|
#ifndef _WIN32_WINNT_WIN8
|
||||||
|
typedef struct _WIN32_MEMORY_RANGE_ENTRY {
|
||||||
|
PVOID VirtualAddress;
|
||||||
|
SIZE_T NumberOfBytes;
|
||||||
|
} WIN32_MEMORY_RANGE_ENTRY, *PWIN32_MEMORY_RANGE_ENTRY;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef BOOL(WINAPI *MDBX_PrefetchVirtualMemory)(
|
||||||
|
HANDLE hProcess, ULONG_PTR NumberOfEntries,
|
||||||
|
PWIN32_MEMORY_RANGE_ENTRY VirtualAddresses, ULONG Flags);
|
||||||
|
extern MDBX_PrefetchVirtualMemory mdbx_PrefetchVirtualMemory;
|
||||||
|
|
||||||
#endif /* Windows */
|
#endif /* Windows */
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user