/ Check-in [da52e6e8]
Login

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

Overview
Comment:Change page quantities in pcache1.c to unsigned.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: da52e6e8b490508bc1ee4700aa45a79f398363da
User & Date: drh 2012-01-02 18:00:55
Context
2012-01-02
18:20
Remove the code that attempts to find the sector size from the OS and hardcode the xSectorSize methods of the unix and windows VFSes to return SQLITE_DEFAULT_SECTOR_SIZE, which is now set to 4096 unless overridden. check-in: 03d8362c user: drh tags: trunk
18:00
Change page quantities in pcache1.c to unsigned. check-in: da52e6e8 user: drh tags: trunk
16:38
Remove an incorrect assert() in btree.c. check-in: c1691d99 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pcache1.c.

    44     44   **
    45     45   ** For mode (1), PGroup.mutex is NULL.  For mode (2) there is only a single
    46     46   ** PGroup which is the pcache1.grp global variable and its mutex is
    47     47   ** SQLITE_MUTEX_STATIC_LRU.
    48     48   */
    49     49   struct PGroup {
    50     50     sqlite3_mutex *mutex;          /* MUTEX_STATIC_LRU or NULL */
    51         -  int nMaxPage;                  /* Sum of nMax for purgeable caches */
    52         -  int nMinPage;                  /* Sum of nMin for purgeable caches */
    53         -  int mxPinned;                  /* nMaxpage + 10 - nMinPage */
    54         -  int nCurrentPage;              /* Number of purgeable pages allocated */
           51  +  unsigned int nMaxPage;         /* Sum of nMax for purgeable caches */
           52  +  unsigned int nMinPage;         /* Sum of nMin for purgeable caches */
           53  +  unsigned int mxPinned;         /* nMaxpage + 10 - nMinPage */
           54  +  unsigned int nCurrentPage;     /* Number of purgeable pages allocated */
    55     55     PgHdr1 *pLruHead, *pLruTail;   /* LRU list of unpinned pages */
    56     56   };
    57     57   
    58     58   /* Each page cache is an instance of the following object.  Every
    59     59   ** open database file (including each in-memory database and each
    60     60   ** temporary or transient database) has a single page cache which
    61     61   ** is an instance of this object.
................................................................................
   710    710   **   5. Otherwise, allocate and return a new page buffer.
   711    711   */
   712    712   static sqlite3_pcache_page *pcache1Fetch(
   713    713     sqlite3_pcache *p, 
   714    714     unsigned int iKey, 
   715    715     int createFlag
   716    716   ){
   717         -  int nPinned;
          717  +  unsigned int nPinned;
   718    718     PCache1 *pCache = (PCache1 *)p;
   719    719     PGroup *pGroup;
   720    720     PgHdr1 *pPage = 0;
   721    721   
   722    722     assert( pCache->bPurgeable || createFlag!=1 );
   723    723     assert( pCache->bPurgeable || pCache->nMin==0 );
   724    724     assert( pCache->bPurgeable==0 || pCache->nMin==10 );
................................................................................
   745    745     ** this point.
   746    746     */
   747    747   #ifdef SQLITE_MUTEX_OMIT
   748    748     pGroup = pCache->pGroup;
   749    749   #endif
   750    750   
   751    751     /* Step 3: Abort if createFlag is 1 but the cache is nearly full */
          752  +  assert( pCache->nPage >= pCache->nRecyclable );
   752    753     nPinned = pCache->nPage - pCache->nRecyclable;
   753         -  assert( nPinned>=0 );
   754    754     assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage );
   755    755     assert( pCache->n90pct == pCache->nMax*9/10 );
   756    756     if( createFlag==1 && (
   757    757           nPinned>=pGroup->mxPinned
   758         -     || nPinned>=(int)pCache->n90pct
          758  +     || nPinned>=pCache->n90pct
   759    759        || pcache1UnderMemoryPressure(pCache)
   760    760     )){
   761    761       goto fetch_out;
   762    762     }
   763    763   
   764    764     if( pCache->nPage>=pCache->nHash && pcache1ResizeHash(pCache) ){
   765    765       goto fetch_out;
................................................................................
   924    924   */
   925    925   static void pcache1Destroy(sqlite3_pcache *p){
   926    926     PCache1 *pCache = (PCache1 *)p;
   927    927     PGroup *pGroup = pCache->pGroup;
   928    928     assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
   929    929     pcache1EnterMutex(pGroup);
   930    930     pcache1TruncateUnsafe(pCache, 0);
          931  +  assert( pGroup->nMaxPage >= pCache->nMax );
   931    932     pGroup->nMaxPage -= pCache->nMax;
          933  +  assert( pGroup->nMinPage >= pCache->nMin );
   932    934     pGroup->nMinPage -= pCache->nMin;
   933    935     pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
   934    936     pcache1EnforceMaxPage(pGroup);
   935    937     pcache1LeaveMutex(pGroup);
   936    938     sqlite3_free(pCache->apHash);
   937    939     sqlite3_free(pCache);
   938    940   }
................................................................................
  1006   1008   ){
  1007   1009     PgHdr1 *p;
  1008   1010     int nRecyclable = 0;
  1009   1011     for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){
  1010   1012       nRecyclable++;
  1011   1013     }
  1012   1014     *pnCurrent = pcache1.grp.nCurrentPage;
  1013         -  *pnMax = pcache1.grp.nMaxPage;
  1014         -  *pnMin = pcache1.grp.nMinPage;
         1015  +  *pnMax = (int)pcache1.grp.nMaxPage;
         1016  +  *pnMin = (int)pcache1.grp.nMinPage;
  1015   1017     *pnRecyclable = nRecyclable;
  1016   1018   }
  1017   1019   #endif