mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Optimize the obscure case of running a checkpoint against a very large wal
file for which a large percentage of the frames have already been checkpointed. FossilOrigin-Name: 0f5057dffa9be1bccab04894709d25bf1f066c4b1aef50d67ee635d46d300a4d
This commit is contained in:
11
src/wal.c
11
src/wal.c
@@ -1585,8 +1585,9 @@ static void walIteratorFree(WalIterator *p){
|
||||
|
||||
/*
|
||||
** Construct a WalInterator object that can be used to loop over all
|
||||
** pages in the WAL in ascending order. The caller must hold the checkpoint
|
||||
** lock.
|
||||
** pages in the WAL following frame nBackfill in ascending order. Frames
|
||||
** nBackfill or earlier may be included - excluding them is an optimization
|
||||
** only. The caller must hold the checkpoint lock.
|
||||
**
|
||||
** On success, make *pp point to the newly allocated WalInterator object
|
||||
** return SQLITE_OK. Otherwise, return an error code. If this routine
|
||||
@@ -1595,7 +1596,7 @@ static void walIteratorFree(WalIterator *p){
|
||||
** The calling routine should invoke walIteratorFree() to destroy the
|
||||
** WalIterator object when it has finished with it.
|
||||
*/
|
||||
static int walIteratorInit(Wal *pWal, WalIterator **pp){
|
||||
static int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){
|
||||
WalIterator *p; /* Return value */
|
||||
int nSegment; /* Number of segments to merge */
|
||||
u32 iLast; /* Last frame in log */
|
||||
@@ -1632,7 +1633,7 @@ static int walIteratorInit(Wal *pWal, WalIterator **pp){
|
||||
rc = SQLITE_NOMEM_BKPT;
|
||||
}
|
||||
|
||||
for(i=0; rc==SQLITE_OK && i<nSegment; i++){
|
||||
for(i=walFramePage(nBackfill+1); rc==SQLITE_OK && i<nSegment; i++){
|
||||
volatile ht_slot *aHash;
|
||||
u32 iZero;
|
||||
volatile u32 *aPgno;
|
||||
@@ -1789,7 +1790,7 @@ static int walCheckpoint(
|
||||
if( pInfo->nBackfill<pWal->hdr.mxFrame ){
|
||||
|
||||
/* Allocate the iterator */
|
||||
rc = walIteratorInit(pWal, &pIter);
|
||||
rc = walIteratorInit(pWal, pInfo->nBackfill, &pIter);
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
|
Reference in New Issue
Block a user