1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

When searching a list of freelist trunk pages looking for a specific page

to allocate, avoid unnecessary journalling of the unchanged trunk pages towards
the start of the list.

FossilOrigin-Name: d03d63d77ed144ac2c02a0245c4b4b070b79c88e
This commit is contained in:
drh
2011-04-07 14:47:01 +00:00
parent fe98f9b216
commit 93b4fc78cf
3 changed files with 12 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
C Avoid\srunning\sthread1.test\sor\sthread2.test\sif\sSQLITE_MUTEX_NOOP\sis\sdefined. C When\ssearching\sa\slist\sof\sfreelist\strunk\spages\slooking\sfor\sa\sspecific\spage\nto\sallocate,\savoid\sunnecessary\sjournalling\sof\sthe\sunchanged\strunk\spages\stowards\nthe\sstart\sof\sthe\slist.
D 2011-04-07T14:05:47.844 D 2011-04-07T14:47:01.943
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -121,7 +121,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
F src/backup.c b7529a6691f0fd534ae8ff622203c46a7f1b626b F src/backup.c b7529a6691f0fd534ae8ff622203c46a7f1b626b
F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef
F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
F src/btree.c 4fcad108b612a4d33dac568b11d26e4d38ccbe35 F src/btree.c 6a9164af8a2ef4612ee30b253635a9bd8e5e1b1b
F src/btree.h 11753dd46597a20702bca8746cb4caa4486a82b5 F src/btree.h 11753dd46597a20702bca8746cb4caa4486a82b5
F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3
F src/build.c b7c993274ee2a029937b0bc4815bdef80b330017 F src/build.c b7c993274ee2a029937b0bc4815bdef80b330017
@@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P e4e99606fdf1f1cecf914dc865b066bf07793d1f P 532ae32ea0f5e821dac643cbc4b041c103cadfdc
R 42c41e910cfc7e1c1b9040c4c34f5e86 R ada284aaaa309102c01ae8aa530bb601
U dan U drh
Z e11fdaaab64fe55fe7338be760f5f876 Z 52b476a7ff4c3a8d80844592d209d819

View File

@@ -1 +1 @@
532ae32ea0f5e821dac643cbc4b041c103cadfdc d03d63d77ed144ac2c02a0245c4b4b070b79c88e

View File

@@ -4819,7 +4819,7 @@ static int allocateBtreePage(
goto end_allocate_page; goto end_allocate_page;
} }
k = get4byte(&pTrunk->aData[4]); k = get4byte(&pTrunk->aData[4]); /* # of leaves on this trunk page */
if( k==0 && !searchList ){ if( k==0 && !searchList ){
/* The trunk has no leaves and the list is not being searched. /* The trunk has no leaves and the list is not being searched.
** So extract the trunk page itself and use it as the newly ** So extract the trunk page itself and use it as the newly
@@ -4904,10 +4904,6 @@ static int allocateBtreePage(
u32 closest; u32 closest;
Pgno iPage; Pgno iPage;
unsigned char *aData = pTrunk->aData; unsigned char *aData = pTrunk->aData;
rc = sqlite3PagerWrite(pTrunk->pDbPage);
if( rc ){
goto end_allocate_page;
}
if( nearby>0 ){ if( nearby>0 ){
u32 i; u32 i;
int dist; int dist;
@@ -4937,11 +4933,12 @@ static int allocateBtreePage(
TRACE(("ALLOCATE: %d was leaf %d of %d on trunk %d" TRACE(("ALLOCATE: %d was leaf %d of %d on trunk %d"
": %d more free pages\n", ": %d more free pages\n",
*pPgno, closest+1, k, pTrunk->pgno, n-1)); *pPgno, closest+1, k, pTrunk->pgno, n-1));
rc = sqlite3PagerWrite(pTrunk->pDbPage);
if( rc ) goto end_allocate_page;
if( closest<k-1 ){ if( closest<k-1 ){
memcpy(&aData[8+closest*4], &aData[4+k*4], 4); memcpy(&aData[8+closest*4], &aData[4+k*4], 4);
} }
put4byte(&aData[4], k-1); put4byte(&aData[4], k-1);
assert( sqlite3PagerIswriteable(pTrunk->pDbPage) );
noContent = !btreeGetHasContent(pBt, *pPgno); noContent = !btreeGetHasContent(pBt, *pPgno);
rc = btreeGetPage(pBt, *pPgno, ppPage, noContent); rc = btreeGetPage(pBt, *pPgno, ppPage, noContent);
if( rc==SQLITE_OK ){ if( rc==SQLITE_OK ){
@@ -5010,6 +5007,7 @@ end_allocate_page:
}else{ }else{
*ppPage = 0; *ppPage = 0;
} }
assert( rc!=SQLITE_OK || sqlite3PagerIswriteable((*ppPage)->pDbPage) );
return rc; return rc;
} }