Eliminate some unnecessary IO during a commit in full auto-vacuum mode. (CVS 5426)
FossilOrigin-Name: 1d01c02ab04f9cc0eb6a2a46a24d3ea63a617d5b
This commit is contained in:
parent
01859b0b07
commit
4c99999965
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\stest\sin\sfunc.test\sso\sthat\sit\sworks\son\smachines\sthat\slack\slong\sdouble.\s(CVS\s5425)
|
||||
D 2008-07-16T18:04:37
|
||||
C Eliminate\ssome\sunnecessary\sIO\sduring\sa\scommit\sin\sfull\sauto-vacuum\smode.\s(CVS\s5426)
|
||||
D 2008-07-16T18:17:56
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in a03f7cb4f7ad50bc53a788c6c544430e81f95de4
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -96,7 +96,7 @@ F src/attach.c b18ba42c77f7d3941f5d23d2ca20fa1d841a4e91
|
||||
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
|
||||
F src/bitvec.c 95c86bd18d8fedf0533f5af196192546e10a7e7d
|
||||
F src/btmutex.c 709cad2cdca0afd013f0f612363810e53f59ec53
|
||||
F src/btree.c cda41ffc78e53cd29e53eab47d174d3e6afd680d
|
||||
F src/btree.c 5dcc47a35d12bc8584d7c89ed113d24fb9fbc2ca
|
||||
F src/btree.h 03256ed7ee42b5ecacbe887070b0f8249e7d069d
|
||||
F src/btreeInt.h a6a5ffab12fa2c15392b85242cd5568371949046
|
||||
F src/build.c bac7233d984be3805aaa41cf500f7ee12dc97249
|
||||
@ -134,8 +134,8 @@ F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
|
||||
F src/os_os2.c b16aee2f727842f758140641835a46caad322f5d
|
||||
F src/os_unix.c 1df6108efdb7957a9f28b9700600e58647c9c12d
|
||||
F src/os_win.c 2bf2f8cd700299564cc236262c2668e1e02c626a
|
||||
F src/pager.c bb286b2fc0c7c87d0a8cbfee96a3e953da1e53dd
|
||||
F src/pager.h 6aa3050a3c684475a5a9dbad5ff1cebad612acba
|
||||
F src/pager.c e65d78bdbd316c3ca0135d2a98ecc607873145aa
|
||||
F src/pager.h 588c1ac195228b2da45c4e5f7ab6c2fd253d1751
|
||||
F src/parse.y 097bff733e89fbf554a07d9327046718ce364011
|
||||
F src/pragma.c 6fad83fbcc7ec6e76d91fe2805fe972ff3af6a0c
|
||||
F src/prepare.c c9bb0aacb7a571d049805699ed18f2bb136ea091
|
||||
@ -608,7 +608,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P 1841aee6045b00cf4ab7b8485f5ab537d5fcd272
|
||||
R 8f639165d0cabfcde66742c2739c4326
|
||||
U drh
|
||||
Z f1ce4c404d5037a5b2007a246716de72
|
||||
P 8686959d4289dc0bf9e1c353b948f26cca5a9a65
|
||||
R b11ed1a66c5f2d78327ee14b0dec1dcc
|
||||
U danielk1977
|
||||
Z b90aebe08a66c9ca365a4e0a71d2b848
|
||||
|
@ -1 +1 @@
|
||||
8686959d4289dc0bf9e1c353b948f26cca5a9a65
|
||||
1d01c02ab04f9cc0eb6a2a46a24d3ea63a617d5b
|
13
src/btree.c
13
src/btree.c
@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.482 2008/07/12 14:52:20 drh Exp $
|
||||
** $Id: btree.c,v 1.483 2008/07/16 18:17:56 danielk1977 Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** See the header comment on "btreeInt.h" for additional information.
|
||||
@ -2112,7 +2112,8 @@ static int relocatePage(
|
||||
MemPage *pDbPage, /* Open page to move */
|
||||
u8 eType, /* Pointer map 'type' entry for pDbPage */
|
||||
Pgno iPtrPage, /* Pointer map 'page-no' entry for pDbPage */
|
||||
Pgno iFreePage /* The location to move pDbPage to */
|
||||
Pgno iFreePage, /* The location to move pDbPage to */
|
||||
int isCommit
|
||||
){
|
||||
MemPage *pPtrPage; /* The page that contains a pointer to pDbPage */
|
||||
Pgno iDbPage = pDbPage->pgno;
|
||||
@ -2127,7 +2128,7 @@ static int relocatePage(
|
||||
/* Move page iDbPage from its current location to page number iFreePage */
|
||||
TRACE(("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n",
|
||||
iDbPage, iFreePage, iPtrPage, eType));
|
||||
rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage);
|
||||
rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit);
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
@ -2277,7 +2278,7 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin){
|
||||
|
||||
rc = sqlite3PagerWrite(pLastPg->pDbPage);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg);
|
||||
rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, nFin!=0);
|
||||
}
|
||||
releasePage(pLastPg);
|
||||
if( rc!=SQLITE_OK ){
|
||||
@ -6030,7 +6031,7 @@ static int btreeCreateTable(Btree *p, int *piTable, int flags){
|
||||
releasePage(pRoot);
|
||||
return rc;
|
||||
}
|
||||
rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove);
|
||||
rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0);
|
||||
releasePage(pRoot);
|
||||
|
||||
/* Obtain the page at pgnoRoot */
|
||||
@ -6238,7 +6239,7 @@ static int btreeDropTable(Btree *p, int iTable, int *piMoved){
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable);
|
||||
rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0);
|
||||
releasePage(pMove);
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
|
24
src/pager.c
24
src/pager.c
@ -18,7 +18,7 @@
|
||||
** file simultaneously, or one process from reading the database while
|
||||
** another is writing.
|
||||
**
|
||||
** @(#) $Id: pager.c,v 1.465 2008/07/11 03:34:10 drh Exp $
|
||||
** @(#) $Id: pager.c,v 1.466 2008/07/16 18:17:56 danielk1977 Exp $
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_DISKIO
|
||||
#include "sqliteInt.h"
|
||||
@ -5184,8 +5184,13 @@ void sqlite3PagerSetCodec(
|
||||
** required that a statement transaction was not active, but this restriction
|
||||
** has been removed (CREATE INDEX needs to move a page when a statement
|
||||
** transaction is active).
|
||||
**
|
||||
** If the fourth argument, isCommit, is non-zero, then this page is being
|
||||
** moved as part of a database reorganization just before the transaction
|
||||
** is being committed. In this case, it is guaranteed that the database page
|
||||
** pPg refers to will not be written to again within this transaction.
|
||||
*/
|
||||
int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno){
|
||||
int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){
|
||||
PgHdr *pPgOld; /* The page being overwritten. */
|
||||
int h;
|
||||
Pgno needSyncPgno = 0;
|
||||
@ -5198,7 +5203,15 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno){
|
||||
IOTRACE(("MOVE %p %d %d\n", pPager, pPg->pgno, pgno))
|
||||
|
||||
pager_get_content(pPg);
|
||||
if( pPg->needSync ){
|
||||
|
||||
/* If the journal needs to be sync()ed before page pPg->pgno can
|
||||
** be written to, store pPg->pgno in local variable needSyncPgno.
|
||||
**
|
||||
** If the isCommit flag is set, there is no need to remember that
|
||||
** the journal needs to be sync()ed before database page pPg->pgno
|
||||
** can be written to. The caller has already promised not to write to it.
|
||||
*/
|
||||
if( pPg->needSync && !isCommit ){
|
||||
needSyncPgno = pPg->pgno;
|
||||
assert( pPg->inJournal || (int)pgno>pPager->origDbSize );
|
||||
assert( pPg->dirty );
|
||||
@ -5245,8 +5258,9 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno){
|
||||
/* If needSyncPgno is non-zero, then the journal file needs to be
|
||||
** sync()ed before any data is written to database file page needSyncPgno.
|
||||
** Currently, no such page exists in the page-cache and the
|
||||
** Pager.pInJournal bit has been set. This needs to be remedied by loading
|
||||
** the page into the pager-cache and setting the PgHdr.needSync flag.
|
||||
** "is journaled" bitvec flag has been set. This needs to be remedied by
|
||||
** loading the page into the pager-cache and setting the PgHdr.needSync
|
||||
** flag.
|
||||
**
|
||||
** If the attempt to load the page into the page-cache fails, (due
|
||||
** to a malloc() or IO failure), clear the bit in the pInJournal[]
|
||||
|
@ -13,7 +13,7 @@
|
||||
** subsystem. The page cache subsystem reads and writes a file a page
|
||||
** at a time and provides a journal for rollback.
|
||||
**
|
||||
** @(#) $Id: pager.h,v 1.76 2008/06/07 08:58:22 danielk1977 Exp $
|
||||
** @(#) $Id: pager.h,v 1.77 2008/07/16 18:17:56 danielk1977 Exp $
|
||||
*/
|
||||
|
||||
#ifndef _PAGER_H_
|
||||
@ -105,7 +105,7 @@ sqlite3_file *sqlite3PagerFile(Pager*);
|
||||
const char *sqlite3PagerDirname(Pager*);
|
||||
const char *sqlite3PagerJournalname(Pager*);
|
||||
int sqlite3PagerNosync(Pager*);
|
||||
int sqlite3PagerMovepage(Pager*,DbPage*,Pgno);
|
||||
int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);
|
||||
void *sqlite3PagerGetData(DbPage *);
|
||||
void *sqlite3PagerGetExtra(DbPage *);
|
||||
int sqlite3PagerLockingMode(Pager *, int);
|
||||
|
Loading…
x
Reference in New Issue
Block a user