From: drh Date: Sat, 27 Jun 2015 03:58:15 +0000 (+0000) Subject: Add the Mempage.aDataOfst field and use it in sqlite3BtreeMovetoUnpacked() X-Git-Tag: version-3.8.11~112 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f44890a7c46cf849498338eb729458ebbea33af8;p=thirdparty%2Fsqlite.git Add the Mempage.aDataOfst field and use it in sqlite3BtreeMovetoUnpacked() for about a 2 million cycle gain. FossilOrigin-Name: bee94dc3510745ba2efa044e8f3299793cfc7e34 --- diff --git a/manifest b/manifest index 1d586dd805..0c5f8a6318 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Treat\scompilation\sof\sFTS5\sfor\sthe\sloadable\sextension\sspecially\swith\sMSVC. -D 2015-06-26T20:45:43.839 +C Add\sthe\sMempage.aDataOfst\sfield\sand\suse\sit\sin\ssqlite3BtreeMovetoUnpacked()\nfor\sabout\sa\s2\smillion\scycle\sgain. +D 2015-06-27T03:58:15.601 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 285a0a234ed7610d431d91671c136098c2bd86a9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -269,9 +269,9 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3 F src/bitvec.c 5eb7958c3bf65210211cbcfc44eff86d0ded7c9d F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c c113f73fc4048038529cc30ed7147b24c34c2c5d +F src/btree.c 2a7554d5607f8ded06bf282c8e9e609a32d9ce55 F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 -F src/btreeInt.h fdd1aff02fb2a63812bd95716e7f579fc3759107 +F src/btreeInt.h 426d1e0d1a15d06b3ad2304f4bedc5bb71e5b4a2 F src/build.c b3f15255d5b16e42dafeaa638fd4f8a47c94ed70 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 @@ -1364,7 +1364,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d27d9965b5404cd32be1113215fd9feeb5b66acc -R 3acd5e6aa6095e21a23b200982f0e53b -U mistachkin -Z ca7f05b6600c190f8e4e9359f2b7edca +P 7c610276bb41dbc80fe169d35fe9a3a3f6525635 +R 762529df533e804d7973bafd804366fc +U drh +Z 0b74e27756355a1dbfb2275608b79e03 diff --git a/manifest.uuid b/manifest.uuid index a120ef2388..34069c5388 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c610276bb41dbc80fe169d35fe9a3a3f6525635 \ No newline at end of file +bee94dc3510745ba2efa044e8f3299793cfc7e34 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 7e6f750b02..bbec2dd0a2 100644 --- a/src/btree.c +++ b/src/btree.c @@ -954,10 +954,16 @@ static int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){ ** the page, 1 means the second cell, and so forth) return a pointer ** to the cell content. ** +** findCellPastPtr() does the same except it skips past the initial +** 4-byte child pointer found on interior pages, if there is one. +** ** This routine works only for pages that do not contain overflow cells. */ #define findCell(P,I) \ ((P)->aData + ((P)->maskPage & get2byte(&(P)->aCellIdx[2*(I)]))) +#define findCellPastPtr(P,I) \ + ((P)->aDataOfst + ((P)->maskPage & get2byte(&(P)->aCellIdx[2*(I)]))) + /* ** This is common tail processing for btreeParseCellPtr() and @@ -1703,6 +1709,7 @@ static int btreeInitPage(MemPage *pPage){ pPage->cellOffset = cellOffset = hdr + 8 + pPage->childPtrSize; pPage->aDataEnd = &data[usableSize]; pPage->aCellIdx = &data[cellOffset]; + pPage->aDataOfst = &data[pPage->childPtrSize]; /* EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates ** the start of the cell content area. A zero value for this integer is ** interpreted as 65536. */ @@ -1822,6 +1829,7 @@ static void zeroPage(MemPage *pPage, int flags){ pPage->cellOffset = first; pPage->aDataEnd = &data[pBt->usableSize]; pPage->aCellIdx = &data[first]; + pPage->aDataOfst = &data[pPage->childPtrSize]; pPage->nOverflow = 0; assert( pBt->pageSize>=512 && pBt->pageSize<=65536 ); pPage->maskPage = (u16)(pBt->pageSize - 1); @@ -5014,7 +5022,7 @@ int sqlite3BtreeMovetoUnpacked( if( xRecordCompare==0 ){ for(;;){ i64 nCellKey; - pCell = findCell(pPage, idx) + pPage->childPtrSize; + pCell = findCellPastPtr(pPage, idx); if( pPage->intKeyLeaf ){ while( 0x80 <= *(pCell++) ){ if( pCell>=pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT; @@ -5047,7 +5055,7 @@ int sqlite3BtreeMovetoUnpacked( }else{ for(;;){ int nCell; /* Size of the pCell cell in bytes */ - pCell = findCell(pPage, idx) + pPage->childPtrSize; + pCell = findCellPastPtr(pPage, idx); /* The maximum supported page-size is 65536 bytes. This means that ** the maximum number of record bytes stored on an index B-Tree diff --git a/src/btreeInt.h b/src/btreeInt.h index 6fc8c45ea3..c4a7f25518 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -295,6 +295,7 @@ struct MemPage { u8 *aData; /* Pointer to disk image of the page data */ u8 *aDataEnd; /* One byte past the end of usable data */ u8 *aCellIdx; /* The cell index area */ + u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */ DbPage *pDbPage; /* Pager page handle */ u16 (*xCellSize)(MemPage*,u8*); /* cellSizePtr method */ void (*xParseCell)(MemPage*,u8*,CellInfo*); /* btreeParseCell method */