Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch winPreCache Excluding Merge-Ins
This is equivalent to a diff from a41d2969 to 360c0fd1
2014-05-09
| ||
11:15 | Add new static mutex SQLITE_MUTEX_STATIC_APP3. (check-in: ee0ab09c user: dan tags: threads) | |
00:36 | Fix several harmless compiler warnings. (Closed-Leaf check-in: 360c0fd1 user: mistachkin tags: winPreCache) | |
2014-05-08
| ||
22:15 | Fix typos in logging code. (check-in: dc7f84df user: mistachkin tags: winPreCache) | |
22:01 | Experimental changes to pre-cache a database file prior to it being fully opened. (check-in: 38cbcedb user: mistachkin tags: winPreCache) | |
22:01 | Fix static variable declaration issue on Windows. (check-in: a41d2969 user: mistachkin tags: threads) | |
2014-05-06
| ||
16:21 | Add a little extra variety to the tests in sort4.test. (check-in: 7de6aee6 user: dan tags: threads) | |
Changes to src/os_win.c.
︙ | ︙ | |||
263 264 265 266 267 268 269 270 271 272 273 274 275 276 | int nFetchOut; /* Number of outstanding xFetch references */ HANDLE hMap; /* Handle for accessing memory mapping */ void *pMapRegion; /* Area memory mapped */ sqlite3_int64 mmapSize; /* Usable size of mapped region */ sqlite3_int64 mmapSizeActual; /* Actual size of mapped region */ sqlite3_int64 mmapSizeMax; /* Configured FCNTL_MMAP_SIZE value */ #endif }; /* ** Allowed values for winFile.ctrlFlags */ #define WINFILE_RDONLY 0x02 /* Connection is read only */ #define WINFILE_PERSIST_WAL 0x04 /* Persistent WAL mode */ | > | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | int nFetchOut; /* Number of outstanding xFetch references */ HANDLE hMap; /* Handle for accessing memory mapping */ void *pMapRegion; /* Area memory mapped */ sqlite3_int64 mmapSize; /* Usable size of mapped region */ sqlite3_int64 mmapSizeActual; /* Actual size of mapped region */ sqlite3_int64 mmapSizeMax; /* Configured FCNTL_MMAP_SIZE value */ #endif SQLiteThread *preCacheThread; /* Thread used to pre-cache file contents */ }; /* ** Allowed values for winFile.ctrlFlags */ #define WINFILE_RDONLY 0x02 /* Connection is read only */ #define WINFILE_PERSIST_WAL 0x04 /* Persistent WAL mode */ |
︙ | ︙ | |||
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 | #else { "CreateFileMappingFromApp", (SYSCALL)0, 0 }, #endif #define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \ LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent) }; /* End of the overrideable system calls */ /* ** This is the xSetSystemCall() method of sqlite3_vfs for all of the ** "win32" VFSes. Return SQLITE_OK opon successfully updating the ** system call pointer, or SQLITE_NOTFOUND if there is no configurable ** system call named zName. | > > > > > | 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 | #else { "CreateFileMappingFromApp", (SYSCALL)0, 0 }, #endif #define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \ LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent) { "DuplicateHandle", (SYSCALL)DuplicateHandle, 0 }, #define osDuplicateHandle ((BOOL(WINAPI*)(HANDLE, \ HANDLE,HANDLE,LPHANDLE,DWORD,BOOL,DWORD))aSyscall[76].pCurrent) }; /* End of the overrideable system calls */ /* ** This is the xSetSystemCall() method of sqlite3_vfs for all of the ** "win32" VFSes. Return SQLITE_OK opon successfully updating the ** system call pointer, or SQLITE_NOTFOUND if there is no configurable ** system call named zName. |
︙ | ︙ | |||
2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 | assert( id!=0 ); #ifndef SQLITE_OMIT_WAL assert( pFile->pShm==0 ); #endif assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE ); OSTRACE(("CLOSE file=%p\n", pFile->h)); #if SQLITE_MAX_MMAP_SIZE>0 winUnmapfile(pFile); #endif do{ rc = osCloseHandle(pFile->h); | > > > > > > > | 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 | assert( id!=0 ); #ifndef SQLITE_OMIT_WAL assert( pFile->pShm==0 ); #endif assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE ); OSTRACE(("CLOSE file=%p\n", pFile->h)); #if SQLITE_MAX_WORKER_THREADS>0 if( pFile->preCacheThread ){ void *pOut = 0; sqlite3ThreadJoin(pFile->preCacheThread, &pOut); } #endif #if SQLITE_MAX_MMAP_SIZE>0 winUnmapfile(pFile); #endif do{ rc = osCloseHandle(pFile->h); |
︙ | ︙ | |||
3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 | ** Return a vector of device characteristics. */ static int winDeviceCharacteristics(sqlite3_file *id){ winFile *p = (winFile*)id; return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0); } /* ** Windows will only let you create file view mappings ** on allocation size granularity boundaries. ** During sqlite3_os_init() we do a GetSystemInfo() ** to get the granularity size. */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 | ** Return a vector of device characteristics. */ static int winDeviceCharacteristics(sqlite3_file *id){ winFile *p = (winFile*)id; return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0); } #if SQLITE_MAX_WORKER_THREADS>0 /* ** Thread routine that attempts to read the entire file. This is used to ** provide a hint to the operating system that the entire file should be held ** in the cache. */ static void *winPreCacheThread(void *pCtx){ winFile *pFile = (winFile*)pCtx; void *pBuf = 0; DWORD lastErrno; HANDLE dupHandle = NULL; DWORD dwSize, dwRet; DWORD dwAmt; DWORD nRead; if( !osDuplicateHandle(GetCurrentProcess(), pFile->h, GetCurrentProcess(), &dupHandle, 0, FALSE, DUPLICATE_SAME_ACCESS) ){ pFile->lastErrno = osGetLastError(); OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR\n", dupHandle)); return SQLITE_INT_TO_PTR(winLogError(SQLITE_IOERR, pFile->lastErrno, "winPreCacheThread1", pFile->zPath)); } dwSize = osSetFilePointer(dupHandle, 0, 0, FILE_END); if( (dwSize==INVALID_SET_FILE_POINTER && ((lastErrno = osGetLastError())!=NO_ERROR)) ){ pFile->lastErrno = lastErrno; osCloseHandle(dupHandle); OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_SEEK\n", dupHandle)); return SQLITE_INT_TO_PTR(winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno, "winPreCacheThread2", pFile->zPath)); } dwRet = osSetFilePointer(dupHandle, 0, 0, FILE_BEGIN); if( (dwRet==INVALID_SET_FILE_POINTER && ((lastErrno = osGetLastError())!=NO_ERROR)) ){ pFile->lastErrno = lastErrno; osCloseHandle(dupHandle); OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_SEEK\n", dupHandle)); return SQLITE_INT_TO_PTR(winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno, "winPreCacheThread3", pFile->zPath)); } dwAmt = 4194304; /* TODO: Tuning. */ if( dwSize<dwAmt ){ dwAmt = dwSize; } pBuf = sqlite3MallocZero( dwAmt ); if( pBuf==0 ){ osCloseHandle(dupHandle); OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_NOMEM\n", dupHandle)); return SQLITE_INT_TO_PTR(SQLITE_IOERR_NOMEM); } while( 1 ){ if( !osReadFile(dupHandle, pBuf, dwAmt, &nRead, 0) ){ pFile->lastErrno = osGetLastError(); sqlite3_free(pBuf); osCloseHandle(dupHandle); OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_READ\n", dupHandle)); return SQLITE_INT_TO_PTR(winLogError(SQLITE_IOERR_READ, pFile->lastErrno, "winPreCacheThread4", pFile->zPath)); } if( nRead<dwAmt ){ sqlite3_free(pBuf); osCloseHandle(dupHandle); OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_SHORT_READ\n", dupHandle)); return SQLITE_INT_TO_PTR(winLogError(SQLITE_IOERR_SHORT_READ, pFile->lastErrno, "winPreCacheThread5", pFile->zPath)); } dwSize -= dwAmt; if( dwSize==0 ){ break; } } sqlite3_free(pBuf); osCloseHandle(dupHandle); return SQLITE_INT_TO_PTR(SQLITE_OK); } #endif /* ** Windows will only let you create file view mappings ** on allocation size granularity boundaries. ** During sqlite3_os_init() we do a GetSystemInfo() ** to get the granularity size. */ |
︙ | ︙ | |||
4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 | #if SQLITE_MAX_MMAP_SIZE>0 pFile->hMap = NULL; pFile->pMapRegion = 0; pFile->mmapSize = 0; pFile->mmapSizeActual = 0; pFile->mmapSizeMax = sqlite3GlobalConfig.szMmap; #endif OpenCounter(+1); return rc; } /* ** Delete the named file. | > > > > > > > > > | 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 | #if SQLITE_MAX_MMAP_SIZE>0 pFile->hMap = NULL; pFile->pMapRegion = 0; pFile->mmapSize = 0; pFile->mmapSizeActual = 0; pFile->mmapSizeMax = sqlite3GlobalConfig.szMmap; #endif #if SQLITE_MAX_WORKER_THREADS>0 sqlite3ThreadCreate(&pFile->preCacheThread, winPreCacheThread, pFile); { void *pOut = 0; sqlite3ThreadJoin(pFile->preCacheThread, &pOut); pFile->preCacheThread = 0; } #endif OpenCounter(+1); return rc; } /* ** Delete the named file. |
︙ | ︙ | |||
5418 5419 5420 5421 5422 5423 5424 | winGetSystemCall, /* xGetSystemCall */ winNextSystemCall, /* xNextSystemCall */ }; #endif /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ | | | 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 | winGetSystemCall, /* xGetSystemCall */ winNextSystemCall, /* xNextSystemCall */ }; #endif /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ assert( ArraySize(aSyscall)==77 ); /* get memory map allocation granularity */ memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); #if SQLITE_OS_WINRT osGetNativeSystemInfo(&winSysInfo); #else osGetSystemInfo(&winSysInfo); |
︙ | ︙ |