mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Optimization: When loading a new page into the cache, avoid redundant memset() calls to zero it. (CVS 6201)
FossilOrigin-Name: 9c0b9f881367871105965d4268e2f2cde7f4d884
This commit is contained in:
22
manifest
22
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\sthe\sVACUUM\scommand\sso\sthat\sit\sdoes\snot\scommit\sa\stransaction\swhen\sit\sis\nmistakenly\srun\swithin\sa\stransaction\s-\sit\sshould\sleave\sthe\stransaction\sopen.\s(CVS\s6200)
|
C Optimization:\sWhen\sloading\sa\snew\spage\sinto\sthe\scache,\savoid\sredundant\smemset()\scalls\sto\szero\sit.\s(CVS\s6201)
|
||||||
D 2009-01-22T23:04:46
|
D 2009-01-23T16:45:01
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in 6619a1b72de7ada2bb7be97862913e27c6f5e339
|
F Makefile.in 6619a1b72de7ada2bb7be97862913e27c6f5e339
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@@ -142,12 +142,12 @@ F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
|
|||||||
F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
|
F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
|
||||||
F src/os_unix.c c74255cc1fcddc38fc3cc1dcf70c2325d3c2948e
|
F src/os_unix.c c74255cc1fcddc38fc3cc1dcf70c2325d3c2948e
|
||||||
F src/os_win.c 496e3ceb499aedc63622a89ef76f7af2dd902709
|
F src/os_win.c 496e3ceb499aedc63622a89ef76f7af2dd902709
|
||||||
F src/pager.c ce7118d56c653c71d6d283006453e49e5bff8b10
|
F src/pager.c be92682af31f44f41c9947f174c5f811648ec68c
|
||||||
F src/pager.h 95b9802f6a014cc55523006f2b893a37b2dc16e3
|
F src/pager.h 869b7027b031e30da24ebe9bdb973d1ec673a96b
|
||||||
F src/parse.y b214295a91e985c42adb6bfd3ad1c56c47828e8d
|
F src/parse.y b214295a91e985c42adb6bfd3ad1c56c47828e8d
|
||||||
F src/pcache.c 48fbfc2208a2734c578b3223fcd4fea7d84f442b
|
F src/pcache.c fcf7738c83c4d3e9d45836b2334c8a368cc41274
|
||||||
F src/pcache.h 9b927ccc5a538e31b4c3bc7eec4f976db42a1324
|
F src/pcache.h 9b927ccc5a538e31b4c3bc7eec4f976db42a1324
|
||||||
F src/pcache1.c c0aa84ff69ea759fa944dbee9167a2463ab7c322
|
F src/pcache1.c dabb8ab14827e090321f17150ce96fda172974e8
|
||||||
F src/pragma.c 04c13c79fd559d769f5bcb3aa661b32d484b1e7b
|
F src/pragma.c 04c13c79fd559d769f5bcb3aa661b32d484b1e7b
|
||||||
F src/prepare.c 9ec504ddd4a8e34e5fb502033312da6a78f5f76a
|
F src/prepare.c 9ec504ddd4a8e34e5fb502033312da6a78f5f76a
|
||||||
F src/printf.c 9866a9a9c4a90f6d4147407f373df3fd5d5f9b6f
|
F src/printf.c 9866a9a9c4a90f6d4147407f373df3fd5d5f9b6f
|
||||||
@@ -156,7 +156,7 @@ F src/resolve.c 18dc9f0df1d60048e012ce6632251063e0dd356a
|
|||||||
F src/rowset.c ba9375f37053d422dd76965a9c370a13b6e1aac4
|
F src/rowset.c ba9375f37053d422dd76965a9c370a13b6e1aac4
|
||||||
F src/select.c ae72b604e47092521c4d9ae54e1b1cbeb872a747
|
F src/select.c ae72b604e47092521c4d9ae54e1b1cbeb872a747
|
||||||
F src/shell.c 0d801ef653fd73d17161afebaab898a58ec3524b
|
F src/shell.c 0d801ef653fd73d17161afebaab898a58ec3524b
|
||||||
F src/sqlite.h.in 6cd2489e40fe97ba58c60044a4ced377e08b6d09
|
F src/sqlite.h.in 8821a61dceff26993ed6689239b6fbcd8d8f6e50
|
||||||
F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
|
F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
|
||||||
F src/sqliteInt.h 086886697368982dd7469689cd6e96c94d091008
|
F src/sqliteInt.h 086886697368982dd7469689cd6e96c94d091008
|
||||||
F src/sqliteLimit.h ffe93f5a0c4e7bd13e70cd7bf84cfb5c3465f45d
|
F src/sqliteLimit.h ffe93f5a0c4e7bd13e70cd7bf84cfb5c3465f45d
|
||||||
@@ -697,7 +697,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
|||||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
P 78ae96def54026461c0d03a90394480f724ea584
|
P 75cc709be46ae2096d2ba3e7ac58de8140f8130c
|
||||||
R b9c2aadad22cb62a07734ad4365fba0e
|
R 8b23ab517890ddeec94bfd9db73627da
|
||||||
U drh
|
U danielk1977
|
||||||
Z 23b2dc2d7661a21482fba1cdc855f298
|
Z 5750c0351bde53b3891c00b777a3ffd1
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
75cc709be46ae2096d2ba3e7ac58de8140f8130c
|
9c0b9f881367871105965d4268e2f2cde7f4d884
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
** file simultaneously, or one process from reading the database while
|
** file simultaneously, or one process from reading the database while
|
||||||
** another is writing.
|
** another is writing.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pager.c,v 1.557 2009/01/22 17:12:40 danielk1977 Exp $
|
** @(#) $Id: pager.c,v 1.558 2009/01/23 16:45:01 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_OMIT_DISKIO
|
#ifndef SQLITE_OMIT_DISKIO
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -3730,6 +3730,7 @@ int sqlite3PagerAcquire(
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
assert( pPg->pgno==pgno );
|
assert( pPg->pgno==pgno );
|
||||||
|
assert( pPg->pPager==pPager || pPg->pPager==0 );
|
||||||
if( pPg->pPager==0 ){
|
if( pPg->pPager==0 ){
|
||||||
/* The pager cache has created a new page. Its content needs to
|
/* The pager cache has created a new page. Its content needs to
|
||||||
** be initialized.
|
** be initialized.
|
||||||
@@ -3737,7 +3738,6 @@ int sqlite3PagerAcquire(
|
|||||||
int nMax;
|
int nMax;
|
||||||
PAGER_INCR(pPager->nMiss);
|
PAGER_INCR(pPager->nMiss);
|
||||||
pPg->pPager = pPager;
|
pPg->pPager = pPager;
|
||||||
memset(pPg->pExtra, 0, pPager->nExtra);
|
|
||||||
|
|
||||||
rc = sqlite3PagerPagecount(pPager, &nMax);
|
rc = sqlite3PagerPagecount(pPager, &nMax);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
@@ -3750,7 +3750,6 @@ int sqlite3PagerAcquire(
|
|||||||
sqlite3PagerUnref(pPg);
|
sqlite3PagerUnref(pPg);
|
||||||
return SQLITE_FULL;
|
return SQLITE_FULL;
|
||||||
}
|
}
|
||||||
memset(pPg->pData, 0, pPager->pageSize);
|
|
||||||
if( noContent ){
|
if( noContent ){
|
||||||
/* Failure to set the bits in the InJournal bit-vectors is benign.
|
/* Failure to set the bits in the InJournal bit-vectors is benign.
|
||||||
** It merely means that we might do some extra work to journal a
|
** It merely means that we might do some extra work to journal a
|
||||||
@@ -3766,6 +3765,8 @@ int sqlite3PagerAcquire(
|
|||||||
TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno);
|
TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno);
|
||||||
testcase( rc==SQLITE_NOMEM );
|
testcase( rc==SQLITE_NOMEM );
|
||||||
sqlite3EndBenignMalloc();
|
sqlite3EndBenignMalloc();
|
||||||
|
}else{
|
||||||
|
memset(pPg->pData, 0, pPager->pageSize);
|
||||||
}
|
}
|
||||||
IOTRACE(("ZERO %p %d\n", pPager, pgno));
|
IOTRACE(("ZERO %p %d\n", pPager, pgno));
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
** subsystem. The page cache subsystem reads and writes a file a page
|
** subsystem. The page cache subsystem reads and writes a file a page
|
||||||
** at a time and provides a journal for rollback.
|
** at a time and provides a journal for rollback.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pager.h,v 1.96 2009/01/20 17:06:27 danielk1977 Exp $
|
** @(#) $Id: pager.h,v 1.97 2009/01/23 16:45:01 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PAGER_H_
|
#ifndef _PAGER_H_
|
||||||
@@ -88,13 +88,13 @@ typedef struct PgHdr DbPage;
|
|||||||
/* Open and close a Pager connection. */
|
/* Open and close a Pager connection. */
|
||||||
int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char*, int,int,int);
|
int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char*, int,int,int);
|
||||||
int sqlite3PagerClose(Pager *pPager);
|
int sqlite3PagerClose(Pager *pPager);
|
||||||
|
int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
|
||||||
|
|
||||||
/* Functions used to configure a Pager object. */
|
/* Functions used to configure a Pager object. */
|
||||||
void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
|
void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
|
||||||
void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*));
|
void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*));
|
||||||
int sqlite3PagerSetPagesize(Pager*, u16*);
|
int sqlite3PagerSetPagesize(Pager*, u16*);
|
||||||
int sqlite3PagerMaxPageCount(Pager*, int);
|
int sqlite3PagerMaxPageCount(Pager*, int);
|
||||||
int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
|
|
||||||
void sqlite3PagerSetCachesize(Pager*, int);
|
void sqlite3PagerSetCachesize(Pager*, int);
|
||||||
void sqlite3PagerSetSafetyLevel(Pager*,int,int);
|
void sqlite3PagerSetSafetyLevel(Pager*,int,int);
|
||||||
int sqlite3PagerLockingMode(Pager *, int);
|
int sqlite3PagerLockingMode(Pager *, int);
|
||||||
|
|||||||
17
src/pcache.c
17
src/pcache.c
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file implements that page cache.
|
** This file implements that page cache.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pcache.c,v 1.42 2009/01/20 17:06:27 danielk1977 Exp $
|
** @(#) $Id: pcache.c,v 1.43 2009/01/23 16:45:01 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -261,14 +261,21 @@ int sqlite3PcacheFetch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( pPage ){
|
if( pPage ){
|
||||||
|
if( !pPage->pData ){
|
||||||
|
memset(pPage, 0, sizeof(PgHdr) + pCache->szExtra);
|
||||||
|
pPage->pExtra = (void*)&pPage[1];
|
||||||
|
pPage->pData = (void *)&((char *)pPage)[sizeof(PgHdr) + pCache->szExtra];
|
||||||
|
pPage->pCache = pCache;
|
||||||
|
pPage->pgno = pgno;
|
||||||
|
}
|
||||||
|
assert( pPage->pCache==pCache );
|
||||||
|
assert( pPage->pgno==pgno );
|
||||||
|
assert( pPage->pExtra==(void *)&pPage[1] );
|
||||||
|
|
||||||
if( 0==pPage->nRef ){
|
if( 0==pPage->nRef ){
|
||||||
pCache->nRef++;
|
pCache->nRef++;
|
||||||
}
|
}
|
||||||
pPage->nRef++;
|
pPage->nRef++;
|
||||||
pPage->pData = (void*)&pPage[1];
|
|
||||||
pPage->pExtra = (void*)&((char*)pPage->pData)[pCache->szPage];
|
|
||||||
pPage->pCache = pCache;
|
|
||||||
pPage->pgno = pgno;
|
|
||||||
if( pgno==1 ){
|
if( pgno==1 ){
|
||||||
pCache->pPage1 = pPage;
|
pCache->pPage1 = pPage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
** If the default page cache implementation is overriden, then neither of
|
** If the default page cache implementation is overriden, then neither of
|
||||||
** these two features are available.
|
** these two features are available.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pcache1.c,v 1.7 2009/01/07 15:18:21 danielk1977 Exp $
|
** @(#) $Id: pcache1.c,v 1.8 2009/01/23 16:45:01 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -201,7 +201,6 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache){
|
|||||||
int nByte = sizeof(PgHdr1) + pCache->szPage;
|
int nByte = sizeof(PgHdr1) + pCache->szPage;
|
||||||
PgHdr1 *p = (PgHdr1 *)pcache1Alloc(nByte);
|
PgHdr1 *p = (PgHdr1 *)pcache1Alloc(nByte);
|
||||||
if( p ){
|
if( p ){
|
||||||
memset(p, 0, nByte);
|
|
||||||
if( pCache->bPurgeable ){
|
if( pCache->bPurgeable ){
|
||||||
pcache1.nCurrentPage++;
|
pcache1.nCurrentPage++;
|
||||||
}
|
}
|
||||||
@@ -550,11 +549,13 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){
|
|||||||
|
|
||||||
if( pPage ){
|
if( pPage ){
|
||||||
unsigned int h = iKey % pCache->nHash;
|
unsigned int h = iKey % pCache->nHash;
|
||||||
memset(pPage, 0, pCache->szPage + sizeof(PgHdr1));
|
*(void **)(PGHDR1_TO_PAGE(pPage)) = 0;
|
||||||
pCache->nPage++;
|
pCache->nPage++;
|
||||||
pPage->iKey = iKey;
|
pPage->iKey = iKey;
|
||||||
pPage->pNext = pCache->apHash[h];
|
pPage->pNext = pCache->apHash[h];
|
||||||
pPage->pCache = pCache;
|
pPage->pCache = pCache;
|
||||||
|
pPage->pLruPrev = 0;
|
||||||
|
pPage->pLruNext = 0;
|
||||||
pCache->apHash[h] = pPage;
|
pCache->apHash[h] = pPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
** the version number) and changes its name to "sqlite3.h" as
|
** the version number) and changes its name to "sqlite3.h" as
|
||||||
** part of the build process.
|
** part of the build process.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqlite.h.in,v 1.421 2008/12/30 06:24:58 danielk1977 Exp $
|
** @(#) $Id: sqlite.h.in,v 1.422 2009/01/23 16:45:01 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITE3_H_
|
#ifndef _SQLITE3_H_
|
||||||
#define _SQLITE3_H_
|
#define _SQLITE3_H_
|
||||||
@@ -6661,17 +6661,17 @@ typedef struct sqlite3_pcache sqlite3_pcache;
|
|||||||
** in which case SQLite will attempt to unpin one or more
|
** in which case SQLite will attempt to unpin one or more
|
||||||
** pages before re-requesting the same page, or it can
|
** pages before re-requesting the same page, or it can
|
||||||
** allocate a new page and return a pointer to it. If a new
|
** allocate a new page and return a pointer to it. If a new
|
||||||
** page is allocated, then it must be completely zeroed before
|
** page is allocated, then the first sizeof(void*) bytes of
|
||||||
** it is returned.
|
** it (at least) must be zeroed before it is returned.
|
||||||
** <tr><td>2<td>If createFlag is set to 2, then SQLite is not holding any
|
** <tr><td>2<td>If createFlag is set to 2, then SQLite is not holding any
|
||||||
** pinned pages associated with the specific cache passed
|
** pinned pages associated with the specific cache passed
|
||||||
** as the first argument to xFetch() that can be unpinned. The
|
** as the first argument to xFetch() that can be unpinned. The
|
||||||
** cache implementation should attempt to allocate a new
|
** cache implementation should attempt to allocate a new
|
||||||
** cache entry and return a pointer to it. Again, the new
|
** cache entry and return a pointer to it. Again, the first
|
||||||
** page should be zeroed before it is returned. If the xFetch()
|
** sizeof(void*) bytes of the page should be zeroed before
|
||||||
** method returns NULL when createFlag==2, SQLite assumes that
|
** it is returned. If the xFetch() method returns NULL when
|
||||||
** a memory allocation failed and returns SQLITE_NOMEM to the
|
** createFlag==2, SQLite assumes that a memory allocation
|
||||||
** user.
|
** failed and returns SQLITE_NOMEM to the user.
|
||||||
** </table>
|
** </table>
|
||||||
**
|
**
|
||||||
** xUnpin() is called by SQLite with a pointer to a currently pinned page
|
** xUnpin() is called by SQLite with a pointer to a currently pinned page
|
||||||
|
|||||||
Reference in New Issue
Block a user