From: drh Date: Fri, 28 Mar 2008 17:41:13 +0000 (+0000) Subject: Change the pager's sector size algorithm to the maximum of the size X-Git-Tag: version-3.6.10~1248 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=334c80d61558f9b7d621080f7924e5177494e051;p=thirdparty%2Fsqlite.git Change the pager's sector size algorithm to the maximum of the size reported by xSectorSize() from the VFS and 512. It was using the maximum of xSectorSize() and the current page size, but that was adding an extra 512 bytes to the size of the journal file in the common case. (CVS 4929) FossilOrigin-Name: 17ea0c97a8bac1b34af1f9183d93a2f2a6af9690 --- diff --git a/manifest b/manifest index 2f9e19883a..bea0039856 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sto\sthe\sMem\sstructure\sto\sreduce\sthe\sfrequency\sof\sfreeing\sand\sreallocating\sthe\sdynamic\sbuffer.\s(CVS\s4928) -D 2008-03-28T15:44:10 +C Change\sthe\spager's\ssector\ssize\salgorithm\sto\sthe\smaximum\sof\sthe\ssize\nreported\sby\sxSectorSize()\sfrom\sthe\sVFS\sand\s512.\s\sIt\swas\susing\sthe\nmaximum\sof\sxSectorSize()\sand\sthe\scurrent\spage\ssize,\sbut\sthat\swas\sadding\nan\sextra\s512\sbytes\sto\sthe\ssize\sof\sthe\sjournal\sfile\sin\sthe\scommon\scase.\s(CVS\s4929) +D 2008-03-28T17:41:14 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in cf434ce8ca902e69126ae0f94fc9f7dc7428a5fa F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -128,7 +128,7 @@ F src/os_unix.c fdec4e5ee5dd555a6ad4a69f38ab35f0788536b4 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_win.c 3a60bddd07ea6f8adb2314dd5996ac97b988f403 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b -F src/pager.c 1cfa9b04f583a141b84af7995b88906e4d90edad +F src/pager.c f8f61c344d6a2406754f761cc223dd31b344830b F src/pager.h b1e2258f03878c14b06a95bfa362e8c5c9638170 F src/parse.y b0ee84d94218046ea88c2a6561005710d127ca7d F src/pragma.c e659c9e443d11854cff2fd250012365ae0ca81ba @@ -344,7 +344,7 @@ F test/insert4.test 6e382eaf7295a4463e6f29ea20fcd8e63d097eeb F test/insert5.test 509017213328147d3acdfa2c441bfd82362dda41 F test/interrupt.test 42e7cf98646fd9cb4a3b131a93ed3c50b9e149f1 F test/intpkey.test 537669fd535f62632ca64828e435b9e54e8d677f -F test/io.test f2e9890eb3f159973fcb11008054596b0caeca4f +F test/io.test cfb907b433a46d5cc3266b292cbfc7cd56ae1234 F test/ioerr.test 5382046b2ef19b9084652e7d2d1e82ab33c0deda F test/ioerr2.test b9c9a0491a812707762a7c002876553be54d9969 F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd @@ -619,7 +619,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P 0a9c63b227b9c6d2bd0e7b491245947ffc83c828 -R 4bbd70b6d864c91be4417b22dd9d1d4c -U danielk1977 -Z 85774c3fc13d70f3eca1b91a57f3702c +P d0bf73d81453da1d8e602e0445064d9f5e348063 +R a00f3c4bc7b82caa5bfcce9be035dea6 +U drh +Z bb8fa8fe977715569e1f6bf0fa970fc0 diff --git a/manifest.uuid b/manifest.uuid index a0fb5b6e0f..3acf74085b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d0bf73d81453da1d8e602e0445064d9f5e348063 \ No newline at end of file +17ea0c97a8bac1b34af1f9183d93a2f2a6af9690 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index d47321a082..61614a6b7a 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.421 2008/03/27 22:42:52 drh Exp $ +** @(#) $Id: pager.c,v 1.422 2008/03/28 17:41:14 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -1683,8 +1683,8 @@ static int pager_truncate(Pager *pPager, int nPage){ /* ** Set the sectorSize for the given pager. ** -** The sector size is the larger of the sector size reported -** by sqlite3OsSectorSize() and the pageSize. +** The sector size is at least as big as the sector size reported +** by sqlite3OsSectorSize(). The minimum sector size is 512. */ static void setSectorSize(Pager *pPager){ assert(pPager->fd->pMethods||pPager->tempFile); @@ -1695,8 +1695,8 @@ static void setSectorSize(Pager *pPager){ */ pPager->sectorSize = sqlite3OsSectorSize(pPager->fd); } - if( pPager->sectorSizepageSize ){ - pPager->sectorSize = pPager->pageSize; + if( pPager->sectorSize<512 ){ + pPager->sectorSize = 512; } } @@ -1714,20 +1714,23 @@ static void setSectorSize(Pager *pPager){ ** sanity checksum. ** (4) 4 byte integer which is the number of pages to truncate the ** database to during a rollback. -** (5) 4 byte integer which is the number of bytes in the master journal +** (5) 4 byte big-endian integer which is the sector size. The header +** is this many bytes in size. +** (6) 4 byte big-endian integer which is the page case. +** (7) 4 byte integer which is the number of bytes in the master journal ** name. The value may be zero (indicate that there is no master ** journal.) -** (6) N bytes of the master journal name. The name will be nul-terminated +** (8) N bytes of the master journal name. The name will be nul-terminated ** and might be shorter than the value read from (5). If the first byte ** of the name is \000 then there is no master journal. The master ** journal name is stored in UTF-8. -** (7) Zero or more pages instances, each as follows: +** (9) Zero or more pages instances, each as follows: ** + 4 byte page number. ** + pPager->pageSize bytes of data. ** + 4 byte checksum ** -** When we speak of the journal header, we mean the first 6 items above. -** Each entry in the journal is an instance of the 7th item. +** When we speak of the journal header, we mean the first 8 items above. +** Each entry in the journal is an instance of the 9th item. ** ** Call the value from the second bullet "nRec". nRec is the number of ** valid page entries in the journal. In most cases, you can compute the diff --git a/test/io.test b/test/io.test index 70d0a96511..1801d9b88d 100644 --- a/test/io.test +++ b/test/io.test @@ -13,7 +13,7 @@ # IO traffic generated by SQLite (making sure SQLite is not writing out # more database pages than it has to, stuff like that). # -# $Id: io.test,v 1.14 2008/01/22 11:50:13 danielk1977 Exp $ +# $Id: io.test,v 1.15 2008/03/28 17:41:14 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -505,7 +505,7 @@ do_test io-4.3.4 { # will not predict the size of the journal file. # file size test.db-journal -} [expr 1024 + (1024+8)*41] +} [expr 512 + (1024+8)*41] #---------------------------------------------------------------------- # Test cases io-5.* test that the default page size is selected and