]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Minor performance improvement and size reduction for the btree-page space
authordrh <drh@noemail.net>
Wed, 20 Aug 2014 00:54:46 +0000 (00:54 +0000)
committerdrh <drh@noemail.net>
Wed, 20 Aug 2014 00:54:46 +0000 (00:54 +0000)
allocator.

FossilOrigin-Name: 73637d12e31f5489efe37d8cf4ab50a1911d4c75

manifest
manifest.uuid
src/btree.c

index c6aee7c71675b14045ccc4e311db302726bd7f0a..91db86833dfc85f9e6454b4ef74d9fc51d175e09 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Modify\sthe\smemsubsys1-3.1.4\stest\sso\sthat\sit\sdoes\snot\sfail\sarbitrarily\sdue\nto\svariations\sin\sthe\sbehavior\sof\ssystem\smalloc().
-D 2014-08-19T23:04:49.204
+C Minor\sperformance\simprovement\sand\ssize\sreduction\sfor\sthe\sbtree-page\sspace\nallocator.
+D 2014-08-20T00:54:46.809
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -167,7 +167,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
 F src/backup.c a729e63cf5cd1829507cb7b8e89f99b95141bb53
 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
-F src/btree.c fa057e30794bfd867963b44a3a42710a45c335a1
+F src/btree.c c580f3fb3b3d1bf968e5c7e6a0ad48b7b0bd4366
 F src/btree.h 4245a349bfe09611d7ff887dbc3a80cee8b7955a
 F src/btreeInt.h cf180d86b2e9e418f638d65baa425c4c69c0e0e3
 F src/build.c 5abf794fe8a605f2005b422e98a3cedad9b9ef5b
@@ -1186,7 +1186,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 44d5bd4cc3f76e9a151ba0abae1092bd184af264
-R da9b4e10fd35ea0494fda63ca4df66ec
+P d280157da0b5275f3e3c875d2dcfb9998d374ac0
+R 020501de111b3b2380806f2152969bc3
 U drh
-Z 375791abd440beaccbf3e162957d1a64
+Z 17df18c00e8e514c309dda1b0357fb11
index a915b839b0d33c24ba7498e40f19a0e94e550f5a..0e6072d88f71e72399e693d8a5822d42439c3180 100644 (file)
@@ -1 +1 @@
-d280157da0b5275f3e3c875d2dcfb9998d374ac0
\ No newline at end of file
+73637d12e31f5489efe37d8cf4ab50a1911d4c75
\ No newline at end of file
index 60bc7de41eb48d26fe9b1aef12cfe1836b2db0b1..2ed304d04b2ccc157a10ec51bf043b89174799c8 100644 (file)
@@ -1197,7 +1197,6 @@ static int defragmentPage(MemPage *pPage){
 static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
   const int hdr = pPage->hdrOffset;    /* Local cache of pPage->hdrOffset */
   u8 * const data = pPage->aData;      /* Local cache of pPage->aData */
-  int nFrag;                           /* Number of fragmented bytes on pPage */
   int top;                             /* First byte of cell content area */
   int gap;        /* First byte of gap between cell pointers and cell content */
   int rc;         /* Integer return code */
@@ -1212,16 +1211,22 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
   usableSize = pPage->pBt->usableSize;
   assert( nByte < usableSize-8 );
 
-  nFrag = data[hdr+7];
   assert( pPage->cellOffset == hdr + 12 - 4*pPage->leaf );
   gap = pPage->cellOffset + 2*pPage->nCell;
-  top = get2byteNotZero(&data[hdr+5]);
-  if( gap>top ) return SQLITE_CORRUPT_BKPT;
+  assert( gap<=65536 );
+  top = get2byte(&data[hdr+5]);
+  if( gap>top ){
+    if( top==0 ){
+      top = 65536;
+    }else{
+      return SQLITE_CORRUPT_BKPT;
+    }
+  }
   testcase( gap+2==top );
   testcase( gap+1==top );
   testcase( gap==top );
 
-  if( nFrag>=60 ){
+  if( data[hdr+7]>=60 ){
     /* Always defragment highly fragmented pages */
     rc = defragmentPage(pPage);
     if( rc ) return rc;
@@ -1246,7 +1251,7 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
           /* Remove the slot from the free-list. Update the number of
           ** fragmented bytes within the page. */
           memcpy(&data[addr], &data[pc], 2);
-          data[hdr+7] = (u8)(nFrag + x);
+          data[hdr+7] += (u8)x;
         }else if( size+pc > usableSize ){
           return SQLITE_CORRUPT_BKPT;
         }else{