-C Add\smunmap\sand\smremap\sto\sthe\sset\sof\sos\sinterfaces\sthat\scan\sbe\soverloaded\nin\sos_unix.c.
-D 2013-03-25T20:50:25.204
+C Memory-mapped\sI/O\sis\snow\son\sby\sdefault.\s\sThe\s"PRAGMA\smmap_limit(N)"\scan\sbe\nused\sto\sissue\sa\shint\sto\sthe\sVFS\sto\slimit\smmap\sspace\sto\sN\sbytes.\s\sThe\sVFS\nis\sfree\sto\signore\sthat\shint\sif\sdesired.\s\sHowever,\sif\s"PRAGMA\smmap_limit(0)"\nis\sused,\sxFetch\sis\snever\scalled.
+D 2013-03-25T23:09:28.646
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in df3e48659d80e1b7765785d8d66c86b320f72cc7
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/backup.c b2cac9f7993f3f9588827b824b1501d0c820fa68
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
-F src/btree.c ef238f2d88c6072cc0d6cff33b72c2a9044a15e4
-F src/btree.h d3259057a38494c4c4358e377032158c762e3d8b
+F src/btree.c 771f0391556317de19e02c9533b256e8299dd59b
+F src/btree.h d9490cd37aaeb530a41b07f06e1262950b1be916
F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2
F src/build.c 083da8466fd7e481cb8bd5264398f537507f6176
F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc
F src/os.c 809d0707cec693e1b9b376ab229271ad74c3d35d
F src/os.h ae08bcc5f6ec6b339f4a2adf3931bb88cc14c3e4
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
-F src/os_unix.c 6b3f972a8b515ce151d1d075080b10d52adbfbd6
+F src/os_unix.c 57306f1d2a2d783dae4365446b9f9a5da8958559
F src/os_win.c e4f17ddf79f2a9373e33ed70565e765d65324589
-F src/pager.c 4e1b55e7a50db0466b06f8ec114799b432c18131
-F src/pager.h 241d72dc0905df042da165f086d03505cb0bb50c
+F src/pager.c c532d51ccc74de8551a28eb932f3b1a1034017d3
+F src/pager.h 5cb78b8e1adfd5451e600be7719f5a99d87ac3b1
F src/parse.y 5d5e12772845805fdfeb889163516b84fbb9ae95
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222
F src/pcache1.c 9fd22671c270b35131ef480bbc00392b8b5f8ab9
-F src/pragma.c 86c8088ac6a12d3f3be5f7394542651f03fa9a38
+F src/pragma.c 8875d32d54530300e6aa31a9d5426b2088a69b12
F src/prepare.c 310eaff1ee5f3c700b3545afb095cfe9346efc3a
F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
F src/select.c 01540bcd3df3c8f1187158e77986028b1c667258
F src/shell.c 7c41bfcd9e5bf9d96b9215f79b03a5b2b44a3bca
-F src/sqlite.h.in 457eb0ba9fbc331281dca53182c90035b087527f
+F src/sqlite.h.in 921ba42ec3531fe8cf021492ffd781b161383f1b
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
F src/sqlite3ext.h 7183ab832e23db0f934494f16928da127a571d75
-F src/sqliteInt.h 2c3d830ae78b046ebf939c905c023610e43c2796
-F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
+F src/sqliteInt.h 0f8f05ee4db4ba9120b38f7a3992b325698f6e8a
+F src/sqliteLimit.h 83d0cd0ce3050a80930406d3c7aecb48c1ccdfc5
F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F src/tclsqlite.c 9a716c737590d2f129d71c8fc7065e5aba0e7222
F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47
F test/date.test f3228180c87bbe5d39c9397bf001c0095c3821b9
F test/dbstatus.test 207e5b63fcb7b9c3bb8e1fdf38ebd4654ad0e54b
-F test/dbstatus2.test 10418e62b3db5dca070f0c3eef3ea13946f339c2
+F test/dbstatus2.test f329941d5f4a8bc0ba6ec5735897ef0cf34e2f5f
F test/default.test 6faf23ccb300114924353007795aa9a8ec0aa9dc
F test/delete.test a065b05d2ebf60fd16639c579a4adfb7c381c701
F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa
F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0
F test/in4.test 64f3cc1acde1b9161ccdd8e5bde3daefdb5b2617
F test/in5.test 99f9a40af01711b06d2d614ecfe96129f334fba3
-F test/incrblob.test e81846d214f3637622620fbde7cd526781cfe328
+F test/incrblob.test 2100cb8964e4a106e5ca9bf80e2c5c3e8be33f77
F test/incrblob2.test edc3a96e557bd61fb39acc8d2edd43371fbbaa19
F test/incrblob3.test aedbb35ea1b6450c33b98f2b6ed98e5020be8dc7
F test/incrblob4.test 09be37d3dd996a31ea6993bba7837ece549414a8
F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
F test/misc7.test dd82ec9250b89178b96cd28b2aca70639d21e5b3
F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054
-F test/mmap1.test e3391ef6c069e5f5733b8339652ce37fd97e3487
+F test/mmap1.test 9fb71daaca72f66fcc7a3b3a37fc3db99988b57a
F test/multiplex.test e08cc7177bd6d85990ee1d71100bb6c684c02256
F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
F test/multiplex3.test d228f59eac91839a977eac19f21d053f03e4d101
F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0
F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16
F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
-F test/permutations.test 5b5397f33b9d129b734b9c57a5091ad494e025c5
+F test/permutations.test d298a74abae42b72b3640dc5505d19d8a3eddc9e
F test/pragma.test 60d29cd3d8098a2c20bf4c072810f99e3bf2757a
F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5
F test/speed1.test f2974a91d79f58507ada01864c0e323093065452
F test/speed1p.explain d841e650a04728b39e6740296b852dccdca9b2cb
-F test/speed1p.test 9912e8f915f1de2c82fc019a63920bf9dcfc69f7
+F test/speed1p.test c4a469f29f135f4d76c55b1f2a52f36e209466cc
F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded
F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523
F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2
F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85
F test/syscall.test a653783d985108c4912cc64d341ffbbb55ad2806
-F test/sysfault.test 3258d6c8213b44f2669994d798a5eb5327b40146
+F test/sysfault.test 503f72712b2b21cb80dc9899e53c2e39484d0313
F test/table.test a59d985ca366e39b17b175f387f9d5db5a18d4e2
F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126
F test/tclsqlite.test 37a61c2da7e3bfe3b8c1a2867199f6b860df5d43
F test/wal2.test d4b470f13c87f6d8268b004380afa04c3c67cb90
F test/wal3.test b22eb662bcbc148c5f6d956eaf94b047f7afe9c0
F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
-F test/wal5.test 091bf7500e97087f1a87b346c8707e93f42d4f80
+F test/wal5.test f4d0aee6a2cf09e326ed2459011d396b4fdf661a
F test/wal6.test 2e3bc767d9c2ce35c47106148d43fcbd072a93b3
F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd
F test/wal8.test b3ee739fe8f7586aaebdc2367f477ebcf3e3b034
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P 431aecc8600c29c203546e48d256510510238887
-R 420b4ff666854b5074068c14722ea276
+P 8776047bd776bbf266eb9c3b56683badb84ae73e
+R 1fba4ef23570acddc66df7d627b1cb5f
U drh
-Z feb03effee9a1e5215de46a6338d0c52
+Z c62aae7ee656f659e8aebd3681920a9a
-8776047bd776bbf266eb9c3b56683badb84ae73e
\ No newline at end of file
+1b37c4effdd03aa2ea938a71b4f22ed27391689b
\ No newline at end of file
** Change the limit on the amount of the database file that may be
** memory mapped.
*/
-int sqlite3BtreeSetMmapSize(Btree *p, int nMap){
+int sqlite3BtreeSetMmapLimit(Btree *p, sqlite3_int64 mxMmap){
BtShared *pBt = p->pBt;
assert( sqlite3_mutex_held(p->db->mutex) );
sqlite3BtreeEnter(p);
- sqlite3PagerSetMmapsize(pBt->pPager, nMap);
+ sqlite3PagerSetMmapLimit(pBt->pPager, mxMmap);
sqlite3BtreeLeave(p);
return SQLITE_OK;
}
int sqlite3BtreeClose(Btree*);
int sqlite3BtreeSetCacheSize(Btree*,int);
-int sqlite3BtreeSetMmapSize(Btree*, int);
+int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);
int sqlite3BtreeSetSafetyLevel(Btree*,int,int,int);
int sqlite3BtreeSyncDisabled(Btree*);
int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
const char *zPath; /* Name of the file */
unixShm *pShm; /* Shared memory segment information */
int szChunk; /* Configured by FCNTL_CHUNK_SIZE */
+ int nFetchOut; /* Number of outstanding xFetch refs */
+ sqlite3_int64 mmapSize; /* Usable size of mapping at pMapRegion */
+ sqlite3_int64 mmapOrigsize; /* Actual size of mapping at pMapRegion */
+ sqlite3_int64 mmapLimit; /* Configured FCNTL_MMAP_LIMIT value */
+ void *pMapRegion; /* Memory mapped region */
#ifdef __QNXNTO__
int sectorSize; /* Device sector size */
int deviceCharacteristics; /* Precomputed device characteristics */
unsigned char inNormalWrite; /* True if in a normal write operation */
#endif
- sqlite3_int64 mmapSize; /* Usable size of mapping at pMapRegion */
- sqlite3_int64 mmapOrigsize; /* Actual size of mapping at pMapRegion */
- sqlite3_int64 mmapLimit; /* Configured FCNTL_MMAP_SIZE value */
- void *pMapRegion; /* Memory mapped region */
- int nFetchOut; /* Number of outstanding xFetch refs */
#ifdef SQLITE_TEST
/* In test mode, increase the size of this structure a bit so that
}
return SQLITE_OK;
}
- case SQLITE_FCNTL_MMAP_SIZE: {
+ case SQLITE_FCNTL_MMAP_LIMIT: {
pFile->mmapLimit = *(i64*)pArg;
return SQLITE_OK;
}
** the mapping to create. Otherwise, if nByte is less than zero, then the
** requested size is the size of the file on disk. The actual size of the
** created mapping is either the requested size or the value configured
-** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller.
+** using SQLITE_FCNTL_MMAP_LIMIT, whichever is smaller.
**
** SQLITE_OK is returned if no error occurs (even if the mapping is not
** recreated as a result of outstanding references) or an SQLite error
pNew->pVfs = pVfs;
pNew->zPath = zFilename;
pNew->ctrlFlags = (u8)ctrlFlags;
+ pNew->mmapLimit = SQLITE_DEFAULT_MMAP_LIMIT;
if( sqlite3_uri_boolean(((ctrlFlags & UNIXFILE_URI) ? zFilename : 0),
"psow", SQLITE_POWERSAFE_OVERWRITE) ){
pNew->ctrlFlags |= UNIXFILE_PSOW;
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
}
/*
-** 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);
}
}
}
/*
** 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);
}
int sqlite3PagerSetPagesize(Pager*, u32*, int);
int sqlite3PagerMaxPageCount(Pager*, int);
void sqlite3PagerSetCachesize(Pager*, int);
-void sqlite3PagerSetMmapsize(Pager *, int);
+void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64);
void sqlite3PagerShrink(Pager*);
void sqlite3PagerSetSafetyLevel(Pager*,int,int,int);
int sqlite3PagerLockingMode(Pager *, int);
}else
/*
- ** PRAGMA [database.]mmap_size
- ** PRAGMA [database.]mmap_size=N
+ ** PRAGMA [database.]mmap_limit(N)
**
- ** Used to set or query the mapping size limit. The mapping size limit is
+ ** Used to set mapping size limit. The mapping size limit is
** used to limit the aggregate size of all memory mapped regions of the
** database file. If this parameter is set to zero, then memory mapping
- ** is not used at all. If it is set to a positive value, then it is
- ** interpreted as a maximum size in pages. If set to less than zero, then
- ** the absolute value is interpreted as a size limit in KB.
+ ** is not used at all. The parameter N is measured in bytes.
**
- ** The default value is zero (do not use memory mapped IO).
+ ** This value is advisory. The underlying VFS is free to memory map
+ ** as little or as much as it wants. Except, if N is set to 0 then the
+ ** upper layers will never invoke the xFetch interfaces to the VFS.
*/
- if( sqlite3StrICmp(zLeft,"mmap_size")==0 ){
+ if( sqlite3StrICmp(zLeft,"mmap_limit")==0 ){
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
- if( !zRight ){
- returnSingleInt(pParse, "mmap_size", pDb->pSchema->mmap_size);
- }else{
- int size = sqlite3Atoi(zRight);
- pDb->pSchema->mmap_size = size;
- sqlite3BtreeSetMmapSize(pDb->pBt, pDb->pSchema->mmap_size);
+ if( zRight ){
+ sqlite3_int64 size;
+ sqlite3Atoi64(zRight, &size, 1000, SQLITE_UTF8);
+ sqlite3BtreeSetMmapLimit(pDb->pBt, size);
}
}else
** written into memory obtained from [sqlite3_malloc()]. The caller should
** invoke [sqlite3_free()] on the result to avoid a memory leak.
**
-** <li>[[SQLITE_FCNTL_MMAP_SIZE]]
-** The argument is assumed to point to a value of type sqlite3_int64. An
-** advisory maximum amount of this file to memory map in bytes.
+** <li>[[SQLITE_FCNTL_MMAP_LIMIT]]
+** The argument is assumed to pointer to a value of type sqlite3_int64 that
+** is an advisory maximum number of bytes in the file to memory map.
**
** </ul>
*/
#define SQLITE_FCNTL_PRAGMA 14
#define SQLITE_FCNTL_BUSYHANDLER 15
#define SQLITE_FCNTL_TEMPFILENAME 16
-#define SQLITE_FCNTL_MMAP_SIZE 18
+#define SQLITE_FCNTL_MMAP_LIMIT 18
/*
** CAPI3REF: Mutex Handle
u8 enc; /* Text encoding used by this database */
u16 flags; /* Flags associated with this schema */
int cache_size; /* Number of pages to use in the cache */
- int mmap_size; /* Number of pages to memory map */
};
/*
#ifndef SQLITE_MAX_TRIGGER_DEPTH
# define SQLITE_MAX_TRIGGER_DEPTH 1000
#endif
+
+/*
+** Default maximum size of memory used by xFetch in the VFS.
+*/
+#ifndef SQLITE_DEFAULT_MMAP_LIMIT
+# define SQLITE_DEFAULT_MMAP_LIMIT (256*1024*1024)
+#endif
do_test 1.1 {
db close
sqlite3 db test.db
- execsql { PRAGMA mmap_size = 0 }
+ execsql { PRAGMA mmap_limit = 0 }
expr {[file size test.db] / 1024}
} 6
forcedelete test.db test.db-journal
sqlite3 db test.db
- execsql "PRAGMA mmap_size = 0"
+ execsql "PRAGMA mmap_limit = 0"
execsql "PRAGMA auto_vacuum = $AutoVacuumMode"
do_test incrblob-2.$AutoVacuumMode.1 {
# Open and close the db to make sure the page cache is empty.
db close
sqlite3 db test.db
- execsql "PRAGMA mmap_size = 0"
+ execsql "PRAGMA mmap_limit = 0"
# Read the last 20 bytes of the blob via a blob handle.
set ::blob [db incrblob blobs v 1]
# Open and close the db to make sure the page cache is empty.
db close
sqlite3 db test.db
- execsql "PRAGMA mmap_size = 0"
+ execsql "PRAGMA mmap_limit = 0"
# Write the second-to-last 20 bytes of the blob via a blob handle.
#
# Open and close the db to make sure the page cache is empty.
db close
sqlite3 db test.db
- execsql { PRAGMA mmap_size = 0 }
+ execsql { PRAGMA mmap_limit = 0 }
execsql { SELECT i FROM blobs }
} {45}
return $stats(read)
}
-foreach {t mmap_size nRead c2init} {
- 1.1 { PRAGMA mmap_size = -65536 } 4 {}
- 1.2 { PRAGMA mmap_size = -50 } 156 {}
- 1.3 { PRAGMA mmap_size = 0 } 344 {}
- 1.4 { PRAGMA mmap_size = -65536 } 4 {PRAGMA mmap_size = -65536}
- 1.5 { PRAGMA mmap_size = -50 } 156 {PRAGMA mmap_size = -65536}
- 1.6 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = -65536}
+foreach {t mmap_limit nRead c2init} {
+ 1.1 { PRAGMA mmap_limit = 70000000 } 4 {}
+ 1.2 { PRAGMA mmap_limit = 51200 } 156 {}
+ 1.3 { PRAGMA mmap_limit = 0 } 344 {}
+ 1.4 { PRAGMA mmap_limit = 70000000 } 4 {PRAGMA mmap_limit = 70000000 }
+ 1.5 { PRAGMA mmap_limit = 51200 } 156 {PRAGMA mmap_limit = 70000000 }
+ 1.6 { PRAGMA mmap_limit = 0 } 344 {PRAGMA mmap_limit = 70000000 }
} {
do_multiclient_test tn {
- sql1 $mmap_size
+ sql1 $mmap_limit
sql2 $c2init
code2 {
} {64 ok 149}
# Check that the number of pages read by connection 1 indicates that the
- # "PRAGMA mmap_size" command worked.
+ # "PRAGMA mmap_limit" command worked.
do_test $t.$tn.5 { nRead db } $nRead
}
}
do_execsql_test 2.1 {
PRAGMA auto_vacuum = 1;
- PRAGMA mmap_size = -65536;
+ PRAGMA mmap_limit = 70000000;
PRAGMA journal_mode = wal;
CREATE TABLE t1(a, b, UNIQUE(a, b));
INSERT INTO t1 VALUES(rblob(500), rblob(500));
} {0 24 24}
finish_test
-
test_set $allquicktests -exclude *malloc* *ioerr* *fault*
]
-test_suite "mmap" -prefix "mm-" -description {
- Similar to veryquick. Except with memory mapping enabled.
+test_suite "no-mmap" -prefix "nomm-" -description {
+ Similar to veryquick. Except with memory mapping disabled.
} -presql {
- pragma mmap_size = -65536;
+ pragma mmap_size = 0;
} -files [
test_set $allquicktests -exclude *malloc* *ioerr* *fault* -include malloc.test
]
#
do_test speed1p-1.0 {
execsql {
- PRAGMA mmap_size=1000000;
PRAGMA page_size=1024;
PRAGMA cache_size=500;
PRAGMA locking_mode=EXCLUSIVE;
faultsim_restore_and_reopen
file_control_chunksize_test db main 8192
execsql {
- PRAGMA mmap_size = 1000000;
+ PRAGMA mmap_limit = 1000000;
}
} -body {
test_syscall errno mmap EACCES
}
finish_test
-
# [sql2] commmand above. So normally, the db is 1 page in size here.
# However, in mmap() mode, the db is pre-allocated to 2 pages at the
# start of the checkpoint, even though page 2 cannot be written.
- set nDb 1
- if {[permutation]=="mmap"} {set nDb 2}
+ set nDb 2
+ if {[permutation]=="no-mmap"} {set nDb 1}
do_test 2.3.$tn.8 { file_page_counts } [list $nDb 4 2 4]
}
finish_test
-