Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Go back to allocating each page and its header with a single memory allocation. This undoes the change of (4409). (CVS 4495) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f56c9884be796dee3f267aca6021eb18 |
User & Date: | drh 2007-10-20 13:17:55.000 |
Context
2007-10-20
| ||
15:41 | Simplify the mem3.c memory allocator. Have it call sqlite3_release_memory() automatically, without having to specify the soft heap limit. (CVS 4496) (check-in: ca51b2f540 user: drh tags: trunk) | |
13:17 | Go back to allocating each page and its header with a single memory allocation. This undoes the change of (4409). (CVS 4495) (check-in: f56c9884be user: drh tags: trunk) | |
12:34 | Fix a mutex leak in the new malloc-free memory allocator. (CVS 4494) (check-in: 30f014d3d0 user: drh tags: trunk) | |
Changes
Changes to src/pager.c.
︙ | ︙ | |||
14 15 16 17 18 19 20 | ** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** ** @(#) $Id: pager.c,v 1.393 2007/10/20 13:17:55 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" #include <assert.h> #include <string.h> /* |
︙ | ︙ | |||
1223 1224 1225 1226 1227 1228 1229 | PgHdr *pPg, *pNext; if( pPager->errCode ) return; for(pPg=pPager->pAll; pPg; pPg=pNext){ IOTRACE(("PGFREE %p %d\n", pPager, pPg->pgno)); PAGER_INCR(sqlite3_pager_pgfree_count); pNext = pPg->pNextAll; lruListRemove(pPg); | < | 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 | PgHdr *pPg, *pNext; if( pPager->errCode ) return; for(pPg=pPager->pAll; pPg; pPg=pNext){ IOTRACE(("PGFREE %p %d\n", pPager, pPg->pgno)); PAGER_INCR(sqlite3_pager_pgfree_count); pNext = pPg->pNextAll; lruListRemove(pPg); sqlite3_free(pPg); } assert(pPager->lru.pFirst==0); assert(pPager->lru.pFirstSynced==0); assert(pPager->lru.pLast==0); pPager->pStmt = 0; pPager->pAll = 0; |
︙ | ︙ | |||
2529 2530 2531 2532 2533 2534 2535 | ppPg = &pPg->pNextAll; }else{ *ppPg = pPg->pNextAll; IOTRACE(("PGFREE %p %d\n", pPager, pPg->pgno)); PAGER_INCR(sqlite3_pager_pgfree_count); unlinkPage(pPg); makeClean(pPg); | < | 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 | ppPg = &pPg->pNextAll; }else{ *ppPg = pPg->pNextAll; IOTRACE(("PGFREE %p %d\n", pPager, pPg->pgno)); PAGER_INCR(sqlite3_pager_pgfree_count); unlinkPage(pPg); makeClean(pPg); sqlite3_free(pPg); pPager->nPage--; } } } /* |
︙ | ︙ | |||
3193 3194 3195 3196 3197 3198 3199 | nReleased += ( sizeof(*pPg) + pPager->pageSize + sizeof(u32) + pPager->nExtra + MEMDB*sizeof(PgHistory) ); IOTRACE(("PGFREE %p %d *\n", pPager, pPg->pgno)); PAGER_INCR(sqlite3_pager_pgfree_count); | < | 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 | nReleased += ( sizeof(*pPg) + pPager->pageSize + sizeof(u32) + pPager->nExtra + MEMDB*sizeof(PgHistory) ); IOTRACE(("PGFREE %p %d *\n", pPager, pPg->pgno)); PAGER_INCR(sqlite3_pager_pgfree_count); sqlite3_free(pPg); pPager->nPage--; }else{ /* An error occured whilst writing to the database file or ** journal in pager_recycle(). The error is not returned to the ** caller of this function. Instead, set the Pager.errCode variable. ** The error will be returned to the user (or users, in the case |
︙ | ︙ | |||
3456 3457 3458 3459 3460 3461 3462 | ** (4) Either there is an available PgHdr that does not need ** to be synced to disk or else disk syncing is currently ** allowed. */ static int pagerAllocatePage(Pager *pPager, PgHdr **ppPg){ int rc = SQLITE_OK; PgHdr *pPg; | | | | < | < < < < < | < < < | | 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 | ** (4) Either there is an available PgHdr that does not need ** to be synced to disk or else disk syncing is currently ** allowed. */ static int pagerAllocatePage(Pager *pPager, PgHdr **ppPg){ int rc = SQLITE_OK; PgHdr *pPg; int nByteHdr; /* Create a new PgHdr if any of the four conditions defined ** above are met: */ if( pPager->nPage<pPager->mxPage || pPager->lru.pFirst==0 || MEMDB || (pPager->lru.pFirstSynced==0 && pPager->doNotSync) ){ if( pPager->nPage>=pPager->nHash ){ pager_resize_hash_table(pPager, pPager->nHash<256 ? 256 : pPager->nHash*2); if( pPager->nHash==0 ){ rc = SQLITE_NOMEM; goto pager_allocate_out; } } pagerLeave(pPager); nByteHdr = sizeof(*pPg) + sizeof(u32) + pPager->nExtra + MEMDB*sizeof(PgHistory); pPg = sqlite3_malloc( nByteHdr + pPager->pageSize ); pagerEnter(pPager); if( pPg==0 ){ rc = SQLITE_NOMEM; goto pager_allocate_out; } memset(pPg, 0, nByteHdr); pPg->pData = (void*)(nByteHdr + (char*)pPg); pPg->pPager = pPager; pPg->pNextAll = pPager->pAll; pPager->pAll = pPg; pPager->nPage++; }else{ /* Recycle an existing page with a zero ref-count. */ rc = pager_recycle(pPager, &pPg); |
︙ | ︙ |