/ Check-in [a1d20ceb]
Login

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

Overview
Comment:An improvement to the SQLITE_FCNTL_SIZE_HINT change that invokes the hint less often and only when really needed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.6.1
Files: files | file ages | folders
SHA1: a1d20ceb9c195ea96f09c2a40c898ca75f504ee1
User & Date: drh 2010-05-17 15:52:44
Context
2010-10-15
14:45
Cherry-pick the change at [2d4505510032bf9] into the 3.6.1 branch. check-in: ecb1419e user: drh tags: branch-3.6.1
2010-05-18
12:37
Keep additional state information in the pager in an effort to reduce the number of SQLITE_FCNTL_SIZE_HINTs. (Note: This change was found to make no performance difference and so has been moved onto a side branch. Use the parent check-in instead of this one.) Closed-Leaf check-in: 97d88a86 user: drh tags: branch-3.6.1-exp
2010-05-17
15:52
An improvement to the SQLITE_FCNTL_SIZE_HINT change that invokes the hint less often and only when really needed. check-in: a1d20ceb user: drh tags: branch-3.6.1
15:33
Invoke the SQLITE_FCNTL_SIZE_HINT opcode on the sqlite3_file_control() interface for database files before extending the size of the file. The VFS can use this hint to preallocate space. check-in: 9a083711 user: drh tags: branch-3.6.1
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/pager.c.

3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
....
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079


3080
3081
3082
3083

3084
3085
3086
3087
3088
3089
3090
** every one of those pages out to the database file and mark them all
** as clean.
*/
static int pager_write_pagelist(PgHdr *pList){
  Pager *pPager;
  PgHdr *p;
  int rc;
  sqlite3_int64 szFile;          /* Final size of databsae file */

  if( pList==0 ) return SQLITE_OK;
  pPager = pList->pPager;

  /* At this point there may be either a RESERVED or EXCLUSIVE lock on the
  ** database file. If there is already an EXCLUSIVE lock, the following
  ** calls to sqlite3OsLock() are no-ops.
................................................................................
  }

  pList = sort_pagelist(pList);
  for(p=pList; p; p=p->pDirty){
    assert( p->dirty );
    p->dirty = 0;
  }
  szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;
  while( pList ){

    /* If the file has not yet been opened, open it now. */
    if( !pPager->fd->pMethods ){
      assert(pPager->tempFile);
      rc = sqlite3PagerOpentemp(pPager, pPager->fd, pPager->vfsFlags);
      if( rc ) return rc;
    }

    /* Before the first write, give the VFS a hint of what the final
    ** file size will be.
    */
    if( szFile>0 ){


      sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);
      szFile = 0;
    }


    /* If there are dirty pages in the page cache with page numbers greater
    ** than Pager.dbSize, this means sqlite3PagerTruncate() was called to
    ** make the file smaller (presumably by auto-vacuum code). Do not write
    ** any such pages to the file.
    */
    if( pList->pgno<=pPager->dbSize ){
      i64 offset = (pList->pgno-1)*(i64)pPager->pageSize;







<







 







<
<

|
|
|
|
|
|

|
|
|
<
>
>
|
<
|

>







3028
3029
3030
3031
3032
3033
3034

3035
3036
3037
3038
3039
3040
3041
....
3058
3059
3060
3061
3062
3063
3064


3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075

3076
3077
3078

3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
** every one of those pages out to the database file and mark them all
** as clean.
*/
static int pager_write_pagelist(PgHdr *pList){
  Pager *pPager;
  PgHdr *p;
  int rc;


  if( pList==0 ) return SQLITE_OK;
  pPager = pList->pPager;

  /* At this point there may be either a RESERVED or EXCLUSIVE lock on the
  ** database file. If there is already an EXCLUSIVE lock, the following
  ** calls to sqlite3OsLock() are no-ops.
................................................................................
  }

  pList = sort_pagelist(pList);
  for(p=pList; p; p=p->pDirty){
    assert( p->dirty );
    p->dirty = 0;
  }



  /* If the file has not yet been opened, open it now. */
  if( !pPager->fd->pMethods ){
    assert(pPager->tempFile);
    rc = sqlite3PagerOpentemp(pPager, pPager->fd, pPager->vfsFlags);
    if( rc ) return rc;
  }

  /* Before the first write, give the VFS a hint of what the final
  ** file size will be.
  */

  if( pPager->dbSize > (pPager->origDbSize+1) ){
    sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;
    sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);

  }

  while( pList ){
    /* If there are dirty pages in the page cache with page numbers greater
    ** than Pager.dbSize, this means sqlite3PagerTruncate() was called to
    ** make the file smaller (presumably by auto-vacuum code). Do not write
    ** any such pages to the file.
    */
    if( pList->pgno<=pPager->dbSize ){
      i64 offset = (pList->pgno-1)*(i64)pPager->pageSize;