diff --git a/manifest b/manifest index c484e547a3..7f1d47fc88 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Replace\sthe\satoi()\slibrary\sroutine\swith\sa\sfaster\shome-grown\sversion\sin\sthe\nVDBE.\s\sThis\sgives\sa\sdramatic\sspeed\simprovement\sfor\ssome\skinds\sof\squeries.\s(CVS\s784) -D 2002-11-11T00:05:43 +C Back\sout\sthe\schanges\sin\sthe\spager\sthat\ssorted\spages\sprior\sto\swriting\sthem\nto\sthe\sdatabase.\s\sAdditional\smeasurements\sshowed\sno\sperformance\sgains.\s(CVS\s785) +D 2002-11-11T01:04:48 F Makefile.in d6c9a85c2a5e696843201d090dcf8bf2f8716f2a F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -32,7 +32,7 @@ F src/main.c f04f93b8928d6d85976e5137fea146a46de1fd6e F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565 F src/os.c caf5a34b35a2d99a58457517261c879ac29b0a05 F src/os.h 1caaea972d1c0401cfe6300aba51fb0f6fe435c9 -F src/pager.c 27d9b94641e968bafabfd2119d9ba4304ccb69a4 +F src/pager.c 691571c468e36212677ed0b1db475dba4dba46bf F src/pager.h 6991c9c2dc5e4c7f2df4d4ba47d1c6458f763a32 F src/parse.y 469c9636ff713e63c00234662209f11668671ae9 F src/printf.c 5c50fc1da75c8f5bf432b1ad17d91d6653acd167 @@ -149,7 +149,7 @@ F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 -P a6ef6657a4377684dc2fce7be2bbf009fd2d2f37 -R 185b0bc33f10b4a768e6cfb7280605c4 +P 263a8ca40f7ff66fbdcb43bf9032391d5b1e68bd +R 0010d81229c7872c45b3b325790678da U drh -Z f3f9009eb197efb6353cb5684648e29d +Z a3b8e3b4a8a73490705deeac8230e339 diff --git a/manifest.uuid b/manifest.uuid index b12c1575b0..75f82f630d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -263a8ca40f7ff66fbdcb43bf9032391d5b1e68bd \ No newline at end of file +745d66395daf5cb8463305bbc9e4219534d2b7cf \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 04c7f25a37..113373377b 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.57 2002/11/10 23:32:57 drh Exp $ +** @(#) $Id: pager.c,v 1.58 2002/11/11 01:04:48 drh Exp $ */ #include "os.h" /* Must be first to enable large file support */ #include "sqliteInt.h" @@ -75,7 +75,6 @@ struct PgHdr { PgHdr *pNextFree, *pPrevFree; /* Freelist of pages where nRef==0 */ PgHdr *pNextAll, *pPrevAll; /* A list of all pages */ PgHdr *pNextCkpt, *pPrevCkpt; /* List of pages in the checkpoint journal */ - PgHdr *pSort; /* Next in list of pages to be written */ u8 inJournal; /* TRUE if has been written to journal */ u8 inCkpt; /* TRUE if written to the checkpoint journal */ u8 dirty; /* TRUE if we need to write back changes */ @@ -794,41 +793,6 @@ int sqlitepager_ref(void *pData){ return SQLITE_OK; } -/* -** The parameters are pointers to the head of two sorted lists -** of page headers. Merge these two lists together and return -** a single sorted list. This routine forms the core of the -** merge-sort algorithm that sorts dirty pages into accending -** order prior to writing them back to the disk. -** -** In the case of a tie, left sorts in front of right. -** -** Headers are sorted in order of ascending page number. -*/ -static PgHdr *page_merge(PgHdr *pLeft, PgHdr *pRight){ - PgHdr sHead; - PgHdr *pTail; - pTail = &sHead; - pTail->pSort = 0; - while( pLeft && pRight ){ - if( pLeft->pgno<=pRight->pgno ){ - pTail->pSort = pLeft; - pLeft = pLeft->pSort; - }else{ - pTail->pSort = pRight; - pRight = pRight->pSort; - } - pTail = pTail->pSort; - } - if( pLeft ){ - pTail->pSort = pLeft; - }else if( pRight ){ - pTail->pSort = pRight; - } - return sHead.pSort; -} - - /* ** Sync the journal and then write all free dirty pages to the database ** file. @@ -845,19 +809,10 @@ static PgHdr *page_merge(PgHdr *pLeft, PgHdr *pRight){ ** If we are writing to temporary database, there is no need to preserve ** the integrity of the journal file, so we can save time and skip the ** fsync(). -** -** This routine goes to the extra trouble of sorting all the dirty -** pages by their page number prior to writing them. Tests show that -** writing pages in order by page number gives a modest speed improvement -** under Linux. */ static int syncAllPages(Pager *pPager){ PgHdr *pPg; - PgHdr *pToWrite; -# define NSORT 28 Pgno lastPgno; - int i; - PgHdr *apSorter[NSORT]; int rc = SQLITE_OK; /* Sync the journal before modifying the main database @@ -871,56 +826,21 @@ static int syncAllPages(Pager *pPager){ pPager->needSync = 0; } - /* Create a list of all dirty pages + /* Write all dirty free pages to the disk in the order that they + ** appear on the disk. We have experimented with sorting the pages + ** by page numbers so that they are written in order, but that does + ** not appear to improve performance. */ - pToWrite = 0; for(pPg=pPager->pFirst; pPg; pPg=pPg->pNextFree){ if( pPg->dirty ){ - pPg->pSort = pToWrite; - pToWrite = pPg; - } - } - - /* Sort the list of dirty pages into accending order by - ** page number - */ - for(i=0; ipSort; - pPg->pSort = 0; - for(i=0; ipgno!=lastPgno+1 ){ + sqliteOsSeek(&pPager->fd, (pPg->pgno-1)*SQLITE_PAGE_SIZE); } + rc = sqliteOsWrite(&pPager->fd, PGHDR_TO_DATA(pPg), SQLITE_PAGE_SIZE); + if( rc!=SQLITE_OK ) break; + pPg->dirty = 0; + lastPgno = pPg->pgno; } - if( i>=NSORT-1 ){ - apSorter[NSORT-1] = page_merge(apSorter[NSORT-1],pPg); - } - } - pToWrite = 0; - for(i=0; ipSort){ - if( lastPgno==0 || pPg->pgno!=lastPgno-1 ){ - sqliteOsSeek(&pPager->fd, (pPg->pgno-1)*SQLITE_PAGE_SIZE); - } - rc = sqliteOsWrite(&pPager->fd, PGHDR_TO_DATA(pPg), SQLITE_PAGE_SIZE); - if( rc!=SQLITE_OK ) break; - pPg->dirty = 0; - lastPgno = pPg->pgno; } return rc; }