1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Memory-mapped I/O is now on by default. The "PRAGMA mmap_limit(N)" can be

used to issue a hint to the VFS to limit mmap space to N bytes.  The VFS
is free to ignore that hint if desired.  However, if "PRAGMA mmap_limit(0)"
is used, xFetch is never called.

FossilOrigin-Name: 1b37c4effdd03aa2ea938a71b4f22ed27391689b
This commit is contained in:
drh
2013-03-25 23:09:28 +00:00
parent d1ab8065c1
commit 0d0614bdc6
18 changed files with 84 additions and 92 deletions

View File

@@ -657,8 +657,8 @@ struct Pager {
char dbFileVers[16]; /* Changes whenever database file changes */
u8 bUseFetch; /* True to use xFetch() */
int nMapCfgLimit; /* Configured limit value */
int nMmapOut; /* Number of mmap pages currently outstanding */
sqlite3_int64 mxMmap; /* Desired maximum mmap size */
PgHdr *pFree; /* List of free mmap page headers (pDirty) */
/*
** End of the routinely-changing class members
@@ -3354,23 +3354,15 @@ void sqlite3PagerSetCachesize(Pager *pPager, int mxPage){
}
/*
** Invoke SQLITE_FCNTL_MMAP_SIZE based on the current value of nMapCfgLimit.
** Invoke SQLITE_FCNTL_MMAP_LIMIT based on the current value of mxMmap.
*/
static void pagerFixMaplimit(Pager *pPager){
sqlite3_file *fd = pPager->fd;
if( isOpen(fd) ){
pPager->bUseFetch = (fd->pMethods->iVersion>=3) && pPager->nMapCfgLimit!=0;
pPager->bUseFetch = (fd->pMethods->iVersion>=3) && pPager->mxMmap>0;
if( pPager->bUseFetch ){
void *p;
i64 nMapLimit;
if( pPager->nMapCfgLimit<0 ){
nMapLimit = (i64)pPager->nMapCfgLimit * -1024;
}else{
nMapLimit = (i64)pPager->nMapCfgLimit * pPager->pageSize;
}
p = (void *)&nMapLimit;
sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_SIZE, p);
sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_LIMIT,
(void*)&pPager->mxMmap);
}
}
}
@@ -3378,8 +3370,8 @@ static void pagerFixMaplimit(Pager *pPager){
/*
** Change the maximum size of any memory mapping made of the database file.
*/
void sqlite3PagerSetMmapsize(Pager *pPager, int nMap){
pPager->nMapCfgLimit = nMap;
void sqlite3PagerSetMmapLimit(Pager *pPager, sqlite3_int64 mxMmap){
pPager->mxMmap = mxMmap;
pagerFixMaplimit(pPager);
}