/ Check-in [b7391892]
Login

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

Overview
Comment:Change the way overflow pages are allocated from the free-list to increase the chance that they are a contiguous block. Much more can still be done. (CVS 4023)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b7391892041eb72b0ebcbb7a9a6721ae3482dd80
User & Date: danielk1977 2007-05-17 18:28:11
Context
2007-05-19
06:48
Add a few extra words to the sqlite3_finalize() documentation. (CVS 4024) check-in: 315dc71b user: danielk1977 tags: trunk
2007-05-17
18:28
Change the way overflow pages are allocated from the free-list to increase the chance that they are a contiguous block. Much more can still be done. (CVS 4023) check-in: b7391892 user: danielk1977 tags: trunk
16:38
Bring the autoconf based build system up to date with the recent changes. #2366, #2367 and #2368. (CVS 4022) check-in: ae644bc7 user: danielk1977 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.382 2007/05/16 17:28:43 danielk1977 Exp $
           12  +** $Id: btree.c,v 1.383 2007/05/17 18:28:11 danielk1977 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   
................................................................................
  3839   3839     *pnSize = info.nSize;
  3840   3840     spaceLeft = info.nLocal;
  3841   3841     pPayload = &pCell[nHeader];
  3842   3842     pPrior = &pCell[info.iOverflow];
  3843   3843   
  3844   3844     while( nPayload>0 ){
  3845   3845       if( spaceLeft==0 ){
         3846  +      int isExact = 0;
  3846   3847   #ifndef SQLITE_OMIT_AUTOVACUUM
  3847   3848         Pgno pgnoPtrmap = pgnoOvfl; /* Overflow page pointer-map entry page */
         3849  +      if( pBt->autoVacuum ){
         3850  +        do{
         3851  +          pgnoOvfl++;
         3852  +        } while( 
         3853  +          PTRMAP_ISPAGE(pBt, pgnoOvfl) || pgnoOvfl==PENDING_BYTE_PAGE(pBt) 
         3854  +        );
         3855  +        if( pgnoOvfl>1 ){
         3856  +          /* isExact = 1; */
         3857  +        }
         3858  +      }
  3848   3859   #endif
  3849         -      rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, 0);
         3860  +      rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, isExact);
  3850   3861   #ifndef SQLITE_OMIT_AUTOVACUUM
  3851   3862         /* If the database supports auto-vacuum, and the second or subsequent
  3852   3863         ** overflow page is being allocated, add an entry to the pointer-map
  3853   3864         ** for that page now. The entry for the first overflow page will be
  3854   3865         ** added later, by the insertCell() routine.
  3855   3866         */
  3856   3867         if( pBt->autoVacuum && pgnoPtrmap!=0 && rc==SQLITE_OK ){

Changes to test/speed3.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #*************************************************************************
    11     11   # This file implements regression tests for SQLite library. The 
    12     12   # focus of this script is testing that the overflow-page related
    13     13   # enhancements added after version 3.3.17 speed things up.
    14     14   #
    15         -# $Id: speed3.test,v 1.1 2007/05/17 14:45:13 danielk1977 Exp $
           15  +# $Id: speed3.test,v 1.2 2007/05/17 18:28:11 danielk1977 Exp $
    16     16   #
    17     17   
    18     18   #---------------------------------------------------------------------
    19     19   # Test plan:
    20     20   #
    21     21   # If auto-vacuum is enabled for the database, the following cases
    22     22   # should show performance improvement with respect to 3.3.17.
................................................................................
    92     92     array set stats1 [btree_pager_stats [btree_from_db db]]
    93     93     array set stats2 [btree_pager_stats [btree_from_db db 2]]
    94     94   # puts "1: [array get stats1]"
    95     95   # puts "2: [array get stats2]"
    96     96     puts "Incrvacuum: Read $stats1(read), wrote $stats1(write)"
    97     97     puts "Normal    : Read $stats2(read), wrote $stats2(write)"
    98     98   }
           99  +
          100  +proc overflow_report {db} {
          101  +  set bt [btree_from_db db]
          102  +  set csr [btree_cursor $bt 3 0]
          103  +
          104  +  for {btree_first $csr} {![btree_eof $csr]} {btree_next $csr} {
          105  +    puts "[btree_ovfl_info $bt $csr]"
          106  +  }
          107  +
          108  +  btree_close_cursor $csr
          109  +  
          110  +}
    99    111   
   100    112   proc reset_db {} {
   101    113     db close
   102    114     sqlite3 db test.db
   103    115     db eval { 
   104    116       PRAGMA main.cache_size = 200000;
   105    117       PRAGMA main.auto_vacuum = 'incremental';
................................................................................
   142    154       PRAGMA aux.auto_vacuum;
   143    155     }
   144    156   } {2 0}
   145    157   
   146    158   # Delete all content in a table, one row at a time.
   147    159   #
   148    160   #io_log db
          161  +#overflow_report db
   149    162   reset_db
   150    163   speed_trial speed3-1.incrvacuum $::NROW row {DELETE FROM main.t1 WHERE 1}
   151    164   speed_trial speed3-1.normal     $::NROW row {DELETE FROM aux.t1 WHERE 1}
   152    165   io_log db
   153    166   
   154    167   # Select the "C" column (located at the far end of the overflow 
   155    168   # chain) from each table row.
   156    169   #
   157         -db eval {PRAGMA incremental_vacuum(500000)}
          170  +#db eval {PRAGMA incremental_vacuum(500000)}
   158    171   populate_t1 db
          172  +#overflow_report db
   159    173   reset_db
   160    174   speed_trial speed3-2.incrvacuum $::NROW row {SELECT c FROM main.t1}
   161    175   speed_trial speed3-2.normal     $::NROW row {SELECT c FROM aux.t1}
   162    176   io_log db
   163    177   
   164    178   finish_test
   165    179