/ Check-in [e2b10714]
Login

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

Overview
Comment:Make the walIndexPage() routine about 3x faster by factoring out the seldom used reallocation logic into a separate subroutine.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e2b107141cd97bd4ab240748a9ce43fc2ec950ea74610697a4a7a3d7a6441e6b
User & Date: drh 2018-02-20 22:20:57
Context
2018-02-21
00:48
Remove an unnecessary memset(). check-in: e7b7f588 user: drh tags: trunk
2018-02-20
22:20
Make the walIndexPage() routine about 3x faster by factoring out the seldom used reallocation logic into a separate subroutine. check-in: e2b10714 user: drh tags: trunk
17:02
In the speed-check.sh script, make WAL mode the default. Add the --legacy option to do DELETE mode. Continue to use DELETE mode for long-term performance graphs since WAL mode was not always available, but use WAL mode for day-to-day performance measurements. check-in: cd816138 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

   550    550   ** so.  It is safe to enlarge the wal-index if pWal->writeLock is true
   551    551   ** or pWal->exclusiveMode==WAL_HEAPMEMORY_MODE.
   552    552   **
   553    553   ** If this call is successful, *ppPage is set to point to the wal-index
   554    554   ** page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs,
   555    555   ** then an SQLite error code is returned and *ppPage is set to 0.
   556    556   */
   557         -static int walIndexPage(Wal *pWal, int iPage, volatile u32 **ppPage){
          557  +static SQLITE_NOINLINE int walIndexPageRealloc(
          558  +  Wal *pWal,               /* The WAL context */
          559  +  int iPage,               /* The page we seek */
          560  +  volatile u32 **ppPage    /* Write the page pointer here */
          561  +){
   558    562     int rc = SQLITE_OK;
   559    563   
   560    564     /* Enlarge the pWal->apWiData[] array if required */
   561    565     if( pWal->nWiData<=iPage ){
   562    566       int nByte = sizeof(u32*)*(iPage+1);
   563    567       volatile u32 **apNew;
   564    568       apNew = (volatile u32 **)sqlite3_realloc64((void *)pWal->apWiData, nByte);
................................................................................
   591    595         }
   592    596       }
   593    597     }
   594    598   
   595    599     *ppPage = pWal->apWiData[iPage];
   596    600     assert( iPage==0 || *ppPage || rc!=SQLITE_OK );
   597    601     return rc;
          602  +}
          603  +static int walIndexPage(
          604  +  Wal *pWal,               /* The WAL context */
          605  +  int iPage,               /* The page we seek */
          606  +  volatile u32 **ppPage    /* Write the page pointer here */
          607  +){
          608  +  if( pWal->nWiData<=iPage || (*ppPage = pWal->apWiData[iPage])==0 ){
          609  +    return walIndexPageRealloc(pWal, iPage, ppPage);
          610  +  }
          611  +  return SQLITE_OK;
   598    612   }
   599    613   
   600    614   /*
   601    615   ** Return a pointer to the WalCkptInfo structure in the wal-index.
   602    616   */
   603    617   static volatile WalCkptInfo *walCkptInfo(Wal *pWal){
   604    618     assert( pWal->nWiData>0 && pWal->apWiData[0] );