/ Check-in [77e099ad]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Optimization to sqltie3BtreeParseCellPtr. 0.3% performance increase. (CVS 5432)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 77e099ad7de84fe07dfeb4c045c769653dd13b93
User & Date: drh 2008-07-18 00:57:33
Context
2008-07-18
02:44
Omit the check for cell-pointer consistency in sqlite3BtreeInitPage() for a 2.5% performance gain. (CVS 5433) check-in: b88087e6 user: drh tags: trunk
00:57
Optimization to sqltie3BtreeParseCellPtr. 0.3% performance increase. (CVS 5432) check-in: 77e099ad user: drh tags: trunk
2008-07-17
18:39
Simplify the b-tree logic by taking advantage of the fact that all b-trees are either intkey+leafdata or zerodata. (CVS 5431) check-in: 29d3bfd7 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.484 2008/07/17 18:39:58 drh Exp $
           12  +** $Id: btree.c,v 1.485 2008/07/18 00:57:33 drh Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** See the header comment on "btreeInt.h" for additional information.
    16     16   ** Including a description of file format and an overview of operation.
    17     17   */
    18     18   #include "btreeInt.h"
    19     19   
................................................................................
   560    560   
   561    561     assert( sqlite3_mutex_held(pPage->pBt->mutex) );
   562    562   
   563    563     pInfo->pCell = pCell;
   564    564     assert( pPage->leaf==0 || pPage->leaf==1 );
   565    565     n = pPage->childPtrSize;
   566    566     assert( n==4-4*pPage->leaf );
   567         -  if( pPage->hasData ){
   568         -    n += getVarint32(&pCell[n], nPayload);
   569         -  }else{
   570         -    nPayload = 0;
   571         -  }
   572         -  pInfo->nData = nPayload;
   573    567     if( pPage->intKey ){
   574         -    n += getVarint(&pCell[n], (u64 *)&pInfo->nKey);
          568  +    if( pPage->hasData ){
          569  +      n += getVarint32(&pCell[n], nPayload);
          570  +    }else{
          571  +      nPayload = 0;
          572  +    }
          573  +    n += getVarint(&pCell[n], (u64*)&pInfo->nKey);
          574  +    pInfo->nData = nPayload;
   575    575     }else{
   576         -    u32 x;
   577         -    n += getVarint32(&pCell[n], x);
   578         -    pInfo->nKey = x;
   579         -    nPayload += x;
          576  +    pInfo->nData = 0;
          577  +    n += getVarint32(&pCell[n], nPayload);
          578  +    pInfo->nKey = nPayload;
   580    579     }
   581    580     pInfo->nPayload = nPayload;
   582    581     pInfo->nHeader = n;
   583         -  if( nPayload<=pPage->maxLocal ){
          582  +  if( likely(nPayload<=pPage->maxLocal) ){
   584    583       /* This is the (easy) common case where the entire payload fits
   585    584       ** on the local page.  No overflow is required.
   586    585       */
   587    586       int nSize;          /* Total size of cell content in bytes */
          587  +    nSize = nPayload + n;
   588    588       pInfo->nLocal = nPayload;
   589    589       pInfo->iOverflow = 0;
   590         -    nSize = nPayload + n;
   591         -    if( nSize<4 ){
          590  +    if( (nSize & ~3)==0 ){
   592    591         nSize = 4;        /* Minimum cell size is 4 */
   593    592       }
   594    593       pInfo->nSize = nSize;
   595    594     }else{
   596    595       /* If the payload will not fit completely on the local page, we have
   597    596       ** to decide how much to store locally and how much to spill onto
   598    597       ** overflow pages.  The strategy is to minimize the amount of unused