mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Speed improvement: do not journal or rollback pages that are pulled out of
the freelist. (CVS 3531) FossilOrigin-Name: 4dffc4c3c9c4ccc024669cec204c68e953333563
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Updates\sto\sthe\s"Distinctive\sFeatures"\sdocument.\s(CVS\s3530)
|
C Speed\simprovement:\sdo\snot\sjournal\sor\srollback\spages\sthat\sare\spulled\sout\sof\nthe\sfreelist.\s(CVS\s3531)
|
||||||
D 2006-12-18T14:12:21
|
D 2006-12-18T18:34:51
|
||||||
F Makefile.in 8e14898d41a53033ecb687d93c9cd5d109fb9ae3
|
F Makefile.in 8e14898d41a53033ecb687d93c9cd5d109fb9ae3
|
||||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -57,7 +57,7 @@ F src/alter.c 2c79ec40f65e33deaf90ca493422c74586e481a3
|
|||||||
F src/analyze.c 7d2b7ab9a9c2fd6e55700f69064dfdd3e36d7a8a
|
F src/analyze.c 7d2b7ab9a9c2fd6e55700f69064dfdd3e36d7a8a
|
||||||
F src/attach.c b11eb4d5d3fb99a10a626956bccc7215f6b68b16
|
F src/attach.c b11eb4d5d3fb99a10a626956bccc7215f6b68b16
|
||||||
F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
|
F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
|
||||||
F src/btree.c 116f748ee11ba4d3630882102e99b60ff58d2a84
|
F src/btree.c e7d1694ad0844918e20b802a249533789bf811dc
|
||||||
F src/btree.h 061c50e37de7f50b58528e352d400cf33ead7418
|
F src/btree.h 061c50e37de7f50b58528e352d400cf33ead7418
|
||||||
F src/build.c 02aedde724dc73295d6e9b8dc29afb5dd38de507
|
F src/build.c 02aedde724dc73295d6e9b8dc29afb5dd38de507
|
||||||
F src/callback.c fd9bb39f7ff6b52bad8365617abc61c720640429
|
F src/callback.c fd9bb39f7ff6b52bad8365617abc61c720640429
|
||||||
@@ -85,7 +85,7 @@ F src/os_unix.c d3b6b66b79777c9177d76bd5c68c227978c4593c
|
|||||||
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
||||||
F src/os_win.c cac5f9b60faacd46874aa8dfefdb7dc4d0437ff9
|
F src/os_win.c cac5f9b60faacd46874aa8dfefdb7dc4d0437ff9
|
||||||
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
||||||
F src/pager.c 18c9cb43b3e740c63eaa13da41c52926012e4853
|
F src/pager.c 814268d5bbd69f30069867142f1d460b8b7ab778
|
||||||
F src/pager.h 2e6d42f4ae004ae748a037b8468112b851c447a7
|
F src/pager.h 2e6d42f4ae004ae748a037b8468112b851c447a7
|
||||||
F src/parse.y 9b3d1c0f8af81fe0cc909baf226865baa725bb23
|
F src/parse.y 9b3d1c0f8af81fe0cc909baf226865baa725bb23
|
||||||
F src/pragma.c d0891d3504b6291b506a5ec2226bbf79ffcef003
|
F src/pragma.c d0891d3504b6291b506a5ec2226bbf79ffcef003
|
||||||
@@ -423,7 +423,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||||
P 7393c81b8cb9d4344ae744de9eabcb3af64f1db8
|
P c734585e1a801bec2d393d000c323ba842c2292d
|
||||||
R 90435cd6f785c0f1944fcee4b97ba9dc
|
R f4b3ee85fc3b4b1abd3912c81ea3b7d4
|
||||||
U drh
|
U drh
|
||||||
Z 785f3b918eb47031e16bc31d88bf41e9
|
Z b8975ee2a0ac067044f47c4bbda872fe
|
||||||
|
@@ -1 +1 @@
|
|||||||
c734585e1a801bec2d393d000c323ba842c2292d
|
4dffc4c3c9c4ccc024669cec204c68e953333563
|
56
src/btree.c
56
src/btree.c
@@ -9,7 +9,7 @@
|
|||||||
** May you share freely, never taking more than you give.
|
** May you share freely, never taking more than you give.
|
||||||
**
|
**
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** $Id: btree.c,v 1.331 2006/11/30 13:05:29 drh Exp $
|
** $Id: btree.c,v 1.332 2006/12/18 18:34:51 drh Exp $
|
||||||
**
|
**
|
||||||
** This file implements a external (disk-based) database using BTrees.
|
** This file implements a external (disk-based) database using BTrees.
|
||||||
** For a detailed discussion of BTrees, refer to
|
** For a detailed discussion of BTrees, refer to
|
||||||
@@ -421,7 +421,8 @@ struct BtCursor {
|
|||||||
*/
|
*/
|
||||||
#if SQLITE_TEST
|
#if SQLITE_TEST
|
||||||
# define TRACE(X) if( sqlite3_btree_trace )\
|
# define TRACE(X) if( sqlite3_btree_trace )\
|
||||||
{ sqlite3DebugPrintf X; fflush(stdout); }
|
/* { sqlite3DebugPrintf X; fflush(stdout); } */ \
|
||||||
|
{ printf X; fflush(stdout); }
|
||||||
int sqlite3_btree_trace=0; /* True to enable tracing */
|
int sqlite3_btree_trace=0; /* True to enable tracing */
|
||||||
#else
|
#else
|
||||||
# define TRACE(X)
|
# define TRACE(X)
|
||||||
@@ -3569,14 +3570,14 @@ static int allocatePage(
|
|||||||
int rc;
|
int rc;
|
||||||
int n; /* Number of pages on the freelist */
|
int n; /* Number of pages on the freelist */
|
||||||
int k; /* Number of leaves on the trunk of the freelist */
|
int k; /* Number of leaves on the trunk of the freelist */
|
||||||
|
MemPage *pTrunk = 0;
|
||||||
|
MemPage *pPrevTrunk = 0;
|
||||||
|
|
||||||
pPage1 = pBt->pPage1;
|
pPage1 = pBt->pPage1;
|
||||||
n = get4byte(&pPage1->aData[36]);
|
n = get4byte(&pPage1->aData[36]);
|
||||||
if( n>0 ){
|
if( n>0 ){
|
||||||
/* There are pages on the freelist. Reuse one of those pages. */
|
/* There are pages on the freelist. Reuse one of those pages. */
|
||||||
MemPage *pTrunk = 0;
|
|
||||||
Pgno iTrunk;
|
Pgno iTrunk;
|
||||||
MemPage *pPrevTrunk = 0;
|
|
||||||
u8 searchList = 0; /* If the free-list must be searched for 'nearby' */
|
u8 searchList = 0; /* If the free-list must be searched for 'nearby' */
|
||||||
|
|
||||||
/* If the 'exact' parameter was true and a query of the pointer-map
|
/* If the 'exact' parameter was true and a query of the pointer-map
|
||||||
@@ -3617,16 +3618,8 @@ static int allocatePage(
|
|||||||
}
|
}
|
||||||
rc = getPage(pBt, iTrunk, &pTrunk);
|
rc = getPage(pBt, iTrunk, &pTrunk);
|
||||||
if( rc ){
|
if( rc ){
|
||||||
releasePage(pPrevTrunk);
|
pTrunk = 0;
|
||||||
return rc;
|
goto end_allocate_page;
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: This should move to after the loop? */
|
|
||||||
rc = sqlite3pager_write(pTrunk->aData);
|
|
||||||
if( rc ){
|
|
||||||
releasePage(pTrunk);
|
|
||||||
releasePage(pPrevTrunk);
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
k = get4byte(&pTrunk->aData[4]);
|
k = get4byte(&pTrunk->aData[4]);
|
||||||
@@ -3635,6 +3628,10 @@ static int allocatePage(
|
|||||||
** So extract the trunk page itself and use it as the newly
|
** So extract the trunk page itself and use it as the newly
|
||||||
** allocated page */
|
** allocated page */
|
||||||
assert( pPrevTrunk==0 );
|
assert( pPrevTrunk==0 );
|
||||||
|
rc = sqlite3pager_write(pTrunk->aData);
|
||||||
|
if( rc ){
|
||||||
|
goto end_allocate_page;
|
||||||
|
}
|
||||||
*pPgno = iTrunk;
|
*pPgno = iTrunk;
|
||||||
memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);
|
memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);
|
||||||
*ppPage = pTrunk;
|
*ppPage = pTrunk;
|
||||||
@@ -3642,7 +3639,8 @@ static int allocatePage(
|
|||||||
TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
|
TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
|
||||||
}else if( k>pBt->usableSize/4 - 8 ){
|
}else if( k>pBt->usableSize/4 - 8 ){
|
||||||
/* Value of k is out of range. Database corruption */
|
/* Value of k is out of range. Database corruption */
|
||||||
return SQLITE_CORRUPT_BKPT;
|
rc = SQLITE_CORRUPT_BKPT;
|
||||||
|
goto end_allocate_page;
|
||||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||||
}else if( searchList && nearby==iTrunk ){
|
}else if( searchList && nearby==iTrunk ){
|
||||||
/* The list is being searched and this trunk page is the page
|
/* The list is being searched and this trunk page is the page
|
||||||
@@ -3651,6 +3649,10 @@ static int allocatePage(
|
|||||||
assert( *pPgno==iTrunk );
|
assert( *pPgno==iTrunk );
|
||||||
*ppPage = pTrunk;
|
*ppPage = pTrunk;
|
||||||
searchList = 0;
|
searchList = 0;
|
||||||
|
rc = sqlite3pager_write(pTrunk->aData);
|
||||||
|
if( rc ){
|
||||||
|
goto end_allocate_page;
|
||||||
|
}
|
||||||
if( k==0 ){
|
if( k==0 ){
|
||||||
if( !pPrevTrunk ){
|
if( !pPrevTrunk ){
|
||||||
memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);
|
memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);
|
||||||
@@ -3666,26 +3668,26 @@ static int allocatePage(
|
|||||||
Pgno iNewTrunk = get4byte(&pTrunk->aData[8]);
|
Pgno iNewTrunk = get4byte(&pTrunk->aData[8]);
|
||||||
rc = getPage(pBt, iNewTrunk, &pNewTrunk);
|
rc = getPage(pBt, iNewTrunk, &pNewTrunk);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
releasePage(pTrunk);
|
goto end_allocate_page;
|
||||||
releasePage(pPrevTrunk);
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
rc = sqlite3pager_write(pNewTrunk->aData);
|
rc = sqlite3pager_write(pNewTrunk->aData);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
releasePage(pNewTrunk);
|
releasePage(pNewTrunk);
|
||||||
releasePage(pTrunk);
|
goto end_allocate_page;
|
||||||
releasePage(pPrevTrunk);
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
memcpy(&pNewTrunk->aData[0], &pTrunk->aData[0], 4);
|
memcpy(&pNewTrunk->aData[0], &pTrunk->aData[0], 4);
|
||||||
put4byte(&pNewTrunk->aData[4], k-1);
|
put4byte(&pNewTrunk->aData[4], k-1);
|
||||||
memcpy(&pNewTrunk->aData[8], &pTrunk->aData[12], (k-1)*4);
|
memcpy(&pNewTrunk->aData[8], &pTrunk->aData[12], (k-1)*4);
|
||||||
|
releasePage(pNewTrunk);
|
||||||
if( !pPrevTrunk ){
|
if( !pPrevTrunk ){
|
||||||
put4byte(&pPage1->aData[32], iNewTrunk);
|
put4byte(&pPage1->aData[32], iNewTrunk);
|
||||||
}else{
|
}else{
|
||||||
|
rc = sqlite3pager_write(pPrevTrunk->aData);
|
||||||
|
if( rc ){
|
||||||
|
goto end_allocate_page;
|
||||||
|
}
|
||||||
put4byte(&pPrevTrunk->aData[0], iNewTrunk);
|
put4byte(&pPrevTrunk->aData[0], iNewTrunk);
|
||||||
}
|
}
|
||||||
releasePage(pNewTrunk);
|
|
||||||
}
|
}
|
||||||
pTrunk = 0;
|
pTrunk = 0;
|
||||||
TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
|
TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
|
||||||
@@ -3695,6 +3697,10 @@ static int allocatePage(
|
|||||||
int closest;
|
int closest;
|
||||||
Pgno iPage;
|
Pgno iPage;
|
||||||
unsigned char *aData = pTrunk->aData;
|
unsigned char *aData = pTrunk->aData;
|
||||||
|
rc = sqlite3pager_write(aData);
|
||||||
|
if( rc ){
|
||||||
|
goto end_allocate_page;
|
||||||
|
}
|
||||||
if( nearby>0 ){
|
if( nearby>0 ){
|
||||||
int i, dist;
|
int i, dist;
|
||||||
closest = 0;
|
closest = 0;
|
||||||
@@ -3738,8 +3744,8 @@ static int allocatePage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
releasePage(pPrevTrunk);
|
releasePage(pPrevTrunk);
|
||||||
|
pPrevTrunk = 0;
|
||||||
}while( searchList );
|
}while( searchList );
|
||||||
releasePage(pTrunk);
|
|
||||||
}else{
|
}else{
|
||||||
/* There are no pages on the freelist, so create a new page at the
|
/* There are no pages on the freelist, so create a new page at the
|
||||||
** end of the file */
|
** end of the file */
|
||||||
@@ -3768,6 +3774,10 @@ static int allocatePage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
|
assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
|
||||||
|
|
||||||
|
end_allocate_page:
|
||||||
|
releasePage(pTrunk);
|
||||||
|
releasePage(pPrevTrunk);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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.276 2006/11/23 11:58:44 drh Exp $
|
** @(#) $Id: pager.c,v 1.277 2006/12/18 18:34:51 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_OMIT_DISKIO
|
#ifndef SQLITE_OMIT_DISKIO
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
** Macros for troubleshooting. Normally turned off
|
** Macros for troubleshooting. Normally turned off
|
||||||
*/
|
*/
|
||||||
#if 0
|
#if 0
|
||||||
|
#define sqlite3DebugPrintf printf
|
||||||
#define TRACE1(X) sqlite3DebugPrintf(X)
|
#define TRACE1(X) sqlite3DebugPrintf(X)
|
||||||
#define TRACE2(X,Y) sqlite3DebugPrintf(X,Y)
|
#define TRACE2(X,Y) sqlite3DebugPrintf(X,Y)
|
||||||
#define TRACE3(X,Y,Z) sqlite3DebugPrintf(X,Y,Z)
|
#define TRACE3(X,Y,Z) sqlite3DebugPrintf(X,Y,Z)
|
||||||
@@ -3335,7 +3336,8 @@ void sqlite3pager_dont_rollback(void *pData){
|
|||||||
PgHdr *pPg = DATA_TO_PGHDR(pData);
|
PgHdr *pPg = DATA_TO_PGHDR(pData);
|
||||||
Pager *pPager = pPg->pPager;
|
Pager *pPager = pPg->pPager;
|
||||||
|
|
||||||
if( pPager->state!=PAGER_EXCLUSIVE || pPager->journalOpen==0 ) return;
|
assert( pPager->state>=PAGER_RESERVED );
|
||||||
|
if( pPager->journalOpen==0 ) return;
|
||||||
if( pPg->alwaysRollback || pPager->alwaysRollback || MEMDB ) return;
|
if( pPg->alwaysRollback || pPager->alwaysRollback || MEMDB ) return;
|
||||||
if( !pPg->inJournal && (int)pPg->pgno <= pPager->origDbSize ){
|
if( !pPg->inJournal && (int)pPg->pgno <= pPager->origDbSize ){
|
||||||
assert( pPager->aInJournal!=0 );
|
assert( pPager->aInJournal!=0 );
|
||||||
|
Reference in New Issue
Block a user