SQLite

Check-in [77e099ad7d]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 77e099ad7de84fe07dfeb4c045c769653dd13b93
User & Date: drh 2008-07-18 00:57:33.000
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: b88087e69d user: drh tags: trunk)
00:57
Optimization to sqltie3BtreeParseCellPtr. 0.3% performance increase. (CVS 5432) (check-in: 77e099ad7d 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: 29d3bfd7c9 user: drh tags: trunk)
Changes
Unified Diff Show Whitespace Changes Patch
Changes to src/btree.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
** 2004 April 6
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.484 2008/07/17 18:39:58 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
** Including a description of file format and an overview of operation.
*/
#include "btreeInt.h"












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
** 2004 April 6
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.485 2008/07/18 00:57:33 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
** Including a description of file format and an overview of operation.
*/
#include "btreeInt.h"

560
561
562
563
564
565
566

567
568
569
570
571

572
573
574
575
576

577
578
579
580
581
582
583
584
585
586
587

588
589
590
591
592
593
594
595
596
597
598

  assert( sqlite3_mutex_held(pPage->pBt->mutex) );

  pInfo->pCell = pCell;
  assert( pPage->leaf==0 || pPage->leaf==1 );
  n = pPage->childPtrSize;
  assert( n==4-4*pPage->leaf );

  if( pPage->hasData ){
    n += getVarint32(&pCell[n], nPayload);
  }else{
    nPayload = 0;
  }

  pInfo->nData = nPayload;
  if( pPage->intKey ){
    n += getVarint(&pCell[n], (u64 *)&pInfo->nKey);
  }else{
    u32 x;

    n += getVarint32(&pCell[n], x);
    pInfo->nKey = x;
    nPayload += x;
  }
  pInfo->nPayload = nPayload;
  pInfo->nHeader = n;
  if( nPayload<=pPage->maxLocal ){
    /* This is the (easy) common case where the entire payload fits
    ** on the local page.  No overflow is required.
    */
    int nSize;          /* Total size of cell content in bytes */

    pInfo->nLocal = nPayload;
    pInfo->iOverflow = 0;
    nSize = nPayload + n;
    if( nSize<4 ){
      nSize = 4;        /* Minimum cell size is 4 */
    }
    pInfo->nSize = nSize;
  }else{
    /* If the payload will not fit completely on the local page, we have
    ** to decide how much to store locally and how much to spill onto
    ** overflow pages.  The strategy is to minimize the amount of unused







>





>

<
<

<
>
|
|
<



|




>


|
<







560
561
562
563
564
565
566
567
568
569
570
571
572
573
574


575

576
577
578

579
580
581
582
583
584
585
586
587
588
589
590

591
592
593
594
595
596
597

  assert( sqlite3_mutex_held(pPage->pBt->mutex) );

  pInfo->pCell = pCell;
  assert( pPage->leaf==0 || pPage->leaf==1 );
  n = pPage->childPtrSize;
  assert( n==4-4*pPage->leaf );
  if( pPage->intKey ){
  if( pPage->hasData ){
    n += getVarint32(&pCell[n], nPayload);
  }else{
    nPayload = 0;
  }
    n += getVarint(&pCell[n], (u64*)&pInfo->nKey);
  pInfo->nData = nPayload;


  }else{

    pInfo->nData = 0;
    n += getVarint32(&pCell[n], nPayload);
    pInfo->nKey = nPayload;

  }
  pInfo->nPayload = nPayload;
  pInfo->nHeader = n;
  if( likely(nPayload<=pPage->maxLocal) ){
    /* This is the (easy) common case where the entire payload fits
    ** on the local page.  No overflow is required.
    */
    int nSize;          /* Total size of cell content in bytes */
    nSize = nPayload + n;
    pInfo->nLocal = nPayload;
    pInfo->iOverflow = 0;
    if( (nSize & ~3)==0 ){

      nSize = 4;        /* Minimum cell size is 4 */
    }
    pInfo->nSize = nSize;
  }else{
    /* If the payload will not fit completely on the local page, we have
    ** to decide how much to store locally and how much to spill onto
    ** overflow pages.  The strategy is to minimize the amount of unused