Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | On commit, flush dirty temp-file pages only if the file is already open and 25% or more of the cache is dirty. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | tempfiles-25 |
Files: | files | file ages | folders |
SHA1: |
f6babf2920340f25815c0a3c58de1e90 |
User & Date: | dan 2016-04-13 16:52:11.775 |
Context
2016-04-13
| ||
19:20 | Merge enhancements from trunk via tempfiles-lazy-open. (check-in: ae16310c4e user: drh tags: tempfiles-25) | |
16:52 | On commit, flush dirty temp-file pages only if the file is already open and 25% or more of the cache is dirty. (check-in: f6babf2920 user: dan tags: tempfiles-25) | |
2016-04-12
| ||
19:09 | Once a temporary database file has been opened, flush all dirty pages to disk when comitting a transaction. (check-in: bbac71aa2a user: dan tags: tempfiles-lazy-open) | |
Changes
Changes to src/pager.c.
︙ | ︙ | |||
1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 | pPager->errCode = rc; pPager->eState = PAGER_ERROR; } return rc; } static int pager_truncate(Pager *pPager, Pgno nPage); /* ** This routine ends a transaction. A transaction is usually ended by ** either a COMMIT or a ROLLBACK operation. This routine may be called ** after rollback of a hot-journal, or if an error occurs while opening ** the journal file or writing the very first journal-header of a ** database transaction. | > > > > > > > > > > > > > > > > > > > | 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 | pPager->errCode = rc; pPager->eState = PAGER_ERROR; } return rc; } static int pager_truncate(Pager *pPager, Pgno nPage); /* ** The write transaction open on the pager passed as the only argument is ** being committed. This function returns true if all dirty pages should ** be flushed to disk, or false otherwise. Pages should be flushed to disk ** unless one of the following is true: ** ** * The db is an in-memory database. ** ** * The db is a temporary database and the db file has not been opened. ** ** * The db is a temporary database and the cache contains less than ** C/4 dirty pages, where C is the configured cache-size. */ static int pagerFlushOnCommit(Pager *pPager){ if( pPager->tempFile==0 ) return 1; if( !isOpen(pPager->fd) ) return 0; return (sqlite3PCachePercentDirty(pPager->pPCache)>=25); } /* ** This routine ends a transaction. A transaction is usually ended by ** either a COMMIT or a ROLLBACK operation. This routine may be called ** after rollback of a hot-journal, or if an error occurs while opening ** the journal file or writing the very first journal-header of a ** database transaction. |
︙ | ︙ | |||
2007 2008 2009 2010 2011 2012 2013 | } } #endif sqlite3BitvecDestroy(pPager->pInJournal); pPager->pInJournal = 0; pPager->nRec = 0; | | | 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 | } } #endif sqlite3BitvecDestroy(pPager->pInJournal); pPager->pInJournal = 0; pPager->nRec = 0; if( pagerFlushOnCommit(pPager) ){ sqlite3PcacheCleanAll(pPager->pPCache); }else{ sqlite3PcacheClearWritable(pPager->pPCache); } sqlite3PcacheTruncate(pPager->pPCache, pPager->dbSize); if( pagerUseWal(pPager) ){ |
︙ | ︙ |
Changes to src/pcache.c.
︙ | ︙ | |||
682 683 684 685 686 687 688 689 690 691 692 693 694 695 | /* ** Return the size of the header added by this middleware layer ** in the page-cache hierarchy. */ int sqlite3HeaderSizePcache(void){ return ROUND8(sizeof(PgHdr)); } #if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG) /* ** For all dirty pages currently in the cache, invoke the specified ** callback. This is only used if the SQLITE_CHECK_PAGES macro is ** defined. */ | > > > > > > > > > > > | 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | /* ** Return the size of the header added by this middleware layer ** in the page-cache hierarchy. */ int sqlite3HeaderSizePcache(void){ return ROUND8(sizeof(PgHdr)); } /* ** Return the number of dirty pages currently in the cache, as a percentage ** of the configured cache size. */ int sqlite3PCachePercentDirty(PCache *pCache){ PgHdr *pDirty; int nDirty = 0; int nCache = numberOfCachePages(pCache); for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext) nDirty++; return (int)(((i64)nDirty * 100) / nCache); } #if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG) /* ** For all dirty pages currently in the cache, invoke the specified ** callback. This is only used if the SQLITE_CHECK_PAGES macro is ** defined. */ |
︙ | ︙ |
Changes to src/pcache.h.
︙ | ︙ | |||
168 169 170 171 172 173 174 175 176 | #endif void sqlite3PCacheSetDefault(void); /* Return the header size */ int sqlite3HeaderSizePcache(void); int sqlite3HeaderSizePcache1(void); #endif /* _PCACHE_H_ */ | > > > | 168 169 170 171 172 173 174 175 176 177 178 179 | #endif void sqlite3PCacheSetDefault(void); /* Return the header size */ int sqlite3HeaderSizePcache(void); int sqlite3HeaderSizePcache1(void); /* Number of dirty pages as a percentage of the configured cache size */ int sqlite3PCachePercentDirty(PCache*); #endif /* _PCACHE_H_ */ |