mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Omit the check for cell-pointer consistency in sqlite3BtreeInitPage()
for a 2.5% performance gain. (CVS 5433) FossilOrigin-Name: b88087e69dffb743c5b552703e14a030349cf65b
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
||||
C Optimization\sto\ssqltie3BtreeParseCellPtr.\s\s0.3%\sperformance\sincrease.\s(CVS\s5432)
|
||||
D 2008-07-18T00:57:33
|
||||
C Omit\sthe\scheck\sfor\scell-pointer\sconsistency\sin\ssqlite3BtreeInitPage()\nfor\sa\s2.5%\sperformance\sgain.\s(CVS\s5433)
|
||||
D 2008-07-18T02:44:18
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in a03f7cb4f7ad50bc53a788c6c544430e81f95de4
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@@ -96,9 +96,9 @@ F src/attach.c b18ba42c77f7d3941f5d23d2ca20fa1d841a4e91
|
||||
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
|
||||
F src/bitvec.c 95c86bd18d8fedf0533f5af196192546e10a7e7d
|
||||
F src/btmutex.c 709cad2cdca0afd013f0f612363810e53f59ec53
|
||||
F src/btree.c 5299a702966d3c32618340cae49cebafc5e93870
|
||||
F src/btree.c 134d2f76fb9144e81b6ca9e426922ac3626d1d77
|
||||
F src/btree.h 03256ed7ee42b5ecacbe887070b0f8249e7d069d
|
||||
F src/btreeInt.h 2aa6dc53b1801bb22815a5be22e03be121f3bd8f
|
||||
F src/btreeInt.h e5b952467935fc29033da138c3d74673329d9770
|
||||
F src/build.c bac7233d984be3805aaa41cf500f7ee12dc97249
|
||||
F src/callback.c aa492a0ad8c2d454edff9fb8a57fae13743cf71d
|
||||
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
|
||||
@@ -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 29d3bfd7c9a68078385354394052612bf812859b
|
||||
R 52c1e00d28149edaa06e0b96ba148399
|
||||
P 77e099ad7de84fe07dfeb4c045c769653dd13b93
|
||||
R c5135664a56b05b1461fc48c1c5e4a98
|
||||
U drh
|
||||
Z ba442f29937e797f8880a62ff02e96e8
|
||||
Z 1e2af38c22a126d0243f54deb66a7f3a
|
||||
|
@@ -1 +1 @@
|
||||
77e099ad7de84fe07dfeb4c045c769653dd13b93
|
||||
b88087e69dffb743c5b552703e14a030349cf65b
|
27
src/btree.c
27
src/btree.c
@@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.485 2008/07/18 00:57:33 drh Exp $
|
||||
** $Id: btree.c,v 1.486 2008/07/18 02:44:18 drh Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** See the header comment on "btreeInt.h" for additional information.
|
||||
@@ -516,8 +516,8 @@ static int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){
|
||||
**
|
||||
** This routine works only for pages that do not contain overflow cells.
|
||||
*/
|
||||
#define findCell(pPage, iCell) \
|
||||
((pPage)->aData + get2byte(&(pPage)->aData[(pPage)->cellOffset+2*(iCell)]))
|
||||
#define findCell(P,I) \
|
||||
((P)->aData + ((P)->maskPage & get2byte(&(P)->aData[(P)->cellOffset+2*(I)])))
|
||||
|
||||
/*
|
||||
** This a more complex version of findCell() that works for
|
||||
@@ -929,9 +929,6 @@ int sqlite3BtreeInitPage(
|
||||
int cellOffset; /* Offset from start of page to first cell pointer */
|
||||
int nFree; /* Number of unused bytes on the page */
|
||||
int top; /* First byte of the cell content area */
|
||||
u8 *pOff; /* Iterator used to check all cell offsets are in range */
|
||||
u8 *pEnd; /* Pointer to end of cell offset array */
|
||||
u8 mask; /* Mask of bits that must be zero in MSB of cell offsets */
|
||||
|
||||
pBt = pPage->pBt;
|
||||
assert( pBt!=0 );
|
||||
@@ -952,6 +949,8 @@ int sqlite3BtreeInitPage(
|
||||
hdr = pPage->hdrOffset;
|
||||
data = pPage->aData;
|
||||
if( decodeFlags(pPage, data[hdr]) ) return SQLITE_CORRUPT_BKPT;
|
||||
assert( pBt->pageSize>=512 && pBt->pageSize<=32768 );
|
||||
pPage->maskPage = pBt->pageSize - 1;
|
||||
pPage->nOverflow = 0;
|
||||
pPage->idxShift = 0;
|
||||
usableSize = pBt->usableSize;
|
||||
@@ -991,13 +990,25 @@ int sqlite3BtreeInitPage(
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
}
|
||||
|
||||
/* Check that all the offsets in the cell offset array are within range. */
|
||||
#if 0
|
||||
/* Check that all the offsets in the cell offset array are within range.
|
||||
**
|
||||
** Omitting this consistency check and using the pPage->maskPage mask
|
||||
** to prevent overrunning the page buffer in findCell() results in a
|
||||
** 2.5% performance gain.
|
||||
*/
|
||||
{
|
||||
u8 *pOff; /* Iterator used to check all cell offsets are in range */
|
||||
u8 *pEnd; /* Pointer to end of cell offset array */
|
||||
u8 mask; /* Mask of bits that must be zero in MSB of cell offsets */
|
||||
mask = ~(((u8)(pBt->pageSize>>8))-1);
|
||||
pEnd = &data[cellOffset + pPage->nCell*2];
|
||||
for(pOff=&data[cellOffset]; pOff!=pEnd && !((*pOff)&mask); pOff+=2);
|
||||
if( pOff!=pEnd ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
pPage->isInit = 1;
|
||||
return SQLITE_OK;
|
||||
@@ -1029,6 +1040,8 @@ static void zeroPage(MemPage *pPage, int flags){
|
||||
pPage->hdrOffset = hdr;
|
||||
pPage->cellOffset = first;
|
||||
pPage->nOverflow = 0;
|
||||
assert( pBt->pageSize>=512 && pBt->pageSize<=32768 );
|
||||
pPage->maskPage = pBt->pageSize - 1;
|
||||
pPage->idxShift = 0;
|
||||
pPage->nCell = 0;
|
||||
pPage->isInit = 1;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btreeInt.h,v 1.27 2008/07/17 18:39:58 drh Exp $
|
||||
** $Id: btreeInt.h,v 1.28 2008/07/18 02:44:18 drh Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** For a detailed discussion of BTrees, refer to
|
||||
@@ -284,6 +284,7 @@ struct MemPage {
|
||||
u16 idxParent; /* Index in parent of this node */
|
||||
u16 nFree; /* Number of free bytes on the page */
|
||||
u16 nCell; /* Number of cells on this page, local and ovfl */
|
||||
u16 maskPage; /* Mask for page offset */
|
||||
struct _OvflCell { /* Cells that will not fit on aData[] */
|
||||
u8 *pCell; /* Pointers to the body of the overflow cell */
|
||||
u16 idx; /* Insert this cell before idx-th non-overflow cell */
|
||||
|
Reference in New Issue
Block a user