/ Check-in [c85202ba]
Login

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

Overview
Comment:Rename the PCache1.mxPinned field to n90pct (since it is 90% of nMax) in order to distinguish it from PGroup.mxPinned. Fix the computation of n90pct so that it does not overflow adversely on excessively large cache sizes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c85202baac49b22a4be36b9733d44f01d83edb28
User & Date: drh 2011-01-26 00:07:03
Context
2011-01-26
06:13
Changes to exclusive2.test to make it more deterministic. check-in: 84b0c2bc user: dan tags: trunk
00:07
Rename the PCache1.mxPinned field to n90pct (since it is 90% of nMax) in order to distinguish it from PGroup.mxPinned. Fix the computation of n90pct so that it does not overflow adversely on excessively large cache sizes. check-in: c85202ba user: drh tags: trunk
2011-01-25
18:30
Fix new compiler warnings in pcache1.c that were introduced by the recent performance enhancement patches of [e14649301138b684]. check-in: c17703ec user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pcache1.c.

    70     70     ** The PGroup mutex must be held when accessing nMax.
    71     71     */
    72     72     PGroup *pGroup;                     /* PGroup this cache belongs to */
    73     73     int szPage;                         /* Size of allocated pages in bytes */
    74     74     int bPurgeable;                     /* True if cache is purgeable */
    75     75     unsigned int nMin;                  /* Minimum number of pages reserved */
    76     76     unsigned int nMax;                  /* Configured "cache_size" value */
    77         -  unsigned int mxPinned;              /* nMax*9/10 */
           77  +  unsigned int n90pct;                /* nMax*9/10 */
    78     78   
    79     79     /* Hash table of all pages. The following variables may only be accessed
    80     80     ** when the accessor is holding the PGroup mutex.
    81     81     */
    82     82     unsigned int nRecyclable;           /* Number of pages in the LRU list */
    83     83     unsigned int nPage;                 /* Total number of pages in apHash */
    84     84     unsigned int nHash;                 /* Number of slots in apHash[] */
................................................................................
   595    595     PCache1 *pCache = (PCache1 *)p;
   596    596     if( pCache->bPurgeable ){
   597    597       PGroup *pGroup = pCache->pGroup;
   598    598       pcache1EnterMutex(pGroup);
   599    599       pGroup->nMaxPage += (nMax - pCache->nMax);
   600    600       pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
   601    601       pCache->nMax = nMax;
   602         -    pCache->mxPinned = nMax*9/10;
          602  +    pCache->n90pct = pCache->nMax*9/10;
   603    603       pcache1EnforceMaxPage(pGroup);
   604    604       pcache1LeaveMutex(pGroup);
   605    605     }
   606    606   }
   607    607   
   608    608   /*
   609    609   ** Implementation of the sqlite3_pcache.xPagecount method. 
................................................................................
   705    705   #ifdef SQLITE_MUTEX_OMIT
   706    706     pGroup = pCache->pGroup;
   707    707   #endif
   708    708   
   709    709   
   710    710     /* Step 3: Abort if createFlag is 1 but the cache is nearly full */
   711    711     nPinned = pCache->nPage - pCache->nRecyclable;
          712  +  assert( nPinned>=0 );
   712    713     assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage );
   713         -  assert( pCache->mxPinned == pCache->nMax*9/10 );
          714  +  assert( pCache->n90pct == pCache->nMax*9/10 );
   714    715     if( createFlag==1 && (
   715    716           nPinned>=pGroup->mxPinned
   716         -     || nPinned>=(int)pCache->mxPinned
          717  +     || nPinned>=(int)pCache->n90pct
   717    718        || pcache1UnderMemoryPressure(pCache)
   718    719     )){
   719    720       goto fetch_out;
   720    721     }
   721    722   
   722    723     if( pCache->nPage>=pCache->nHash && pcache1ResizeHash(pCache) ){
   723    724       goto fetch_out;