From: danielk1977 Date: Wed, 29 Apr 2009 11:31:47 +0000 (+0000) Subject: Add a version of cellSizePtr() that is faster than using sqlite3BtreeParseCellPtr... X-Git-Tag: version-3.6.15~184 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae5558b2ae0d3e22621adf8c2b5ee9814b6ece30;p=thirdparty%2Fsqlite.git Add a version of cellSizePtr() that is faster than using sqlite3BtreeParseCellPtr(). This speeds up balance_nonroot(). (CVS 6566) FossilOrigin-Name: e8f7f7b787fe941093edaea44db4d361fad1e002 --- diff --git a/manifest b/manifest index db2e83aebc..d9f289bd8d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplify\sa\sconditional\sexpression\sin\sbtree.c.\s(CVS\s6565) -D 2009-04-29T06:27:57 +C Add\sa\sversion\sof\scellSizePtr()\sthat\sis\sfaster\sthan\susing\ssqlite3BtreeParseCellPtr().\sThis\sspeeds\sup\sbalance_nonroot().\s(CVS\s6566) +D 2009-04-29T11:31:47 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -106,7 +106,7 @@ F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627 F src/backup.c 0082d0e5a63f04e88faee0dff0a7d63d3e92a78d F src/bitvec.c ef370407e03440b0852d05024fb016b14a471d3d F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c -F src/btree.c 3dffdafe21bf727f0e3409436ac65e3d7b319673 +F src/btree.c d3e38cf751251096c2d2017ff9f2375e29bf0f99 F src/btree.h 99fcc7e8c4a1e35afe271bcb38de1a698dfc904e F src/btreeInt.h df64030d632f8c8ac217ed52e8b6b3eacacb33a5 F src/build.c dca0ad77c88cb00f6a11cc080a4f3285672cfa37 @@ -725,7 +725,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P e855654283a23d903fd531162655a8c4fa01775b -R 63c07503296c76f396fee3ac325064a0 +P fc3a5ac2353142082fe14d47f9c2b662407ea3f7 +R 7f4b713c43e75500014d39ff57631373 U danielk1977 -Z 5dbb9b5bf3757053f2c4aad47a67a72e +Z 7a846e8596d6c8f108ba0f337c171b19 diff --git a/manifest.uuid b/manifest.uuid index e8ba734d59..6d5b72f7a7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fc3a5ac2353142082fe14d47f9c2b662407ea3f7 \ No newline at end of file +e8f7f7b787fe941093edaea44db4d361fad1e002 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index ec1957bf53..7ff7c806c4 100644 --- a/src/btree.c +++ b/src/btree.c @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btree.c,v 1.597 2009/04/29 06:27:57 danielk1977 Exp $ +** $Id: btree.c,v 1.598 2009/04/29 11:31:47 danielk1977 Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** See the header comment on "btreeInt.h" for additional information. @@ -762,18 +762,59 @@ void sqlite3BtreeParseCell( ** data header and the local payload, but not any overflow page or ** the space used by the cell pointer. */ +static u16 cellSizePtr(MemPage *pPage, u8 *pCell){ + u8 *pIter = &pCell[pPage->childPtrSize]; + u32 nSize; + +#ifdef SQLITE_DEBUG + /* The value returned by this function should always be the same as + ** the (CellInfo.nSize) value found by doing a full parse of the + ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of + ** this function verifies that this invariant is not violated. */ + CellInfo debuginfo; + sqlite3BtreeParseCellPtr(pPage, pCell, &debuginfo); +#endif + + if( pPage->intKey ){ + u8 *pEnd; + if( pPage->hasData ){ + pIter += getVarint32(pIter, nSize); + }else{ + nSize = 0; + } + + /* pIter now points at the 64-bit integer key value, a variable length + ** integer. The following block moves pIter to point at the first byte + ** past the end of the key value. */ + pEnd = &pIter[9]; + while( (*pIter++)&0x80 && pIterpPage->maxLocal ){ + int minLocal = pPage->minLocal; + nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4); + if( nSize>pPage->maxLocal ){ + nSize = minLocal; + } + nSize += 4; + } + nSize += (pIter - pCell); + + /* The minimum size of any cell is 4 bytes. */ + if( nSize<4 ){ + nSize = 4; + } + + assert( nSize==debuginfo.nSize ); + return nSize; +} #ifndef NDEBUG static u16 cellSize(MemPage *pPage, int iCell){ - CellInfo info; - sqlite3BtreeParseCell(pPage, iCell, &info); - return info.nSize; + return cellSizePtr(pPage, findCell(pPage, iCell)); } #endif -static u16 cellSizePtr(MemPage *pPage, u8 *pCell){ - CellInfo info; - sqlite3BtreeParseCellPtr(pPage, pCell, &info); - return info.nSize; -} #ifndef SQLITE_OMIT_AUTOVACUUM /*