]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Speed up releaseMemArray() a bit by handling the most common types of memory cells...
authordanielk1977 <danielk1977@noemail.net>
Fri, 19 Sep 2008 18:32:26 +0000 (18:32 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Fri, 19 Sep 2008 18:32:26 +0000 (18:32 +0000)
FossilOrigin-Name: ce07508550da858beb0bc0763c65e6d556bb0843

manifest
manifest.uuid
src/vdbeaux.c

index c059e8eaa2cd012d00835704a946ccf7a010a87d..68b8a6bebbc241423c1d05987b750c6a0cc09a0f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C In\sfunction\smoveToRoot(),\suse\sthe\sMemPage.pParent\spointers\sto\sfind\sthe\sroot\spage\sif\sthey\sare\svalid.\sThis\sis\sslightly\sfaster\sthan\srequesting\sa\snew\sreference\sto\sthe\sroot\spage\sfrom\sthe\spager\slayer.\s(CVS\s5725)
-D 2008-09-19T16:39:38
+C Speed\sup\sreleaseMemArray()\sa\sbit\sby\shandling\sthe\smost\scommon\stypes\sof\smemory\scells\sinline.\s(CVS\s5726)
+D 2008-09-19T18:32:27
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in d15a7ebfe5e057a72a49805ffb302dbb601c8329
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -193,7 +193,7 @@ F src/vdbe.c ebc6f6bc8663ca00b6c7ed41bc464023dd6e0483
 F src/vdbe.h 41c99aaad9167c1b5431993db446de74b2f71fc3
 F src/vdbeInt.h b48c74d86a9fb62b707a3186ccca76bb32f1c6be
 F src/vdbeapi.c c0f87aabb2bcf8c760ff9cb289119f7f6ba1797a
-F src/vdbeaux.c e1198d1ea2e129bd56863794a223da670e1359c7
+F src/vdbeaux.c 20a7d109c95e32beee7891fba828c63e419af26c
 F src/vdbeblob.c f93110888ddc246215e9ba1f831d3d375bfd8355
 F src/vdbefifo.c 20fda2a7c4c0bcee1b90eb7e545fefcdbf2e1de7
 F src/vdbemem.c ead88713b852576e2a924bc4ae696964bfbaec0a
@@ -637,7 +637,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 59be34cfa4fe74f7e5b547c55d273ecba9d7796c
-R f3d27e1b16af35370468dd13d616f41c
+P 0c8b74e668b7462c5439c04993d1d7cd74210075
+R 0c4f9fcda4509cdf163057aa76c78a60
 U danielk1977
-Z c019239d82228e28c9df258ace82b690
+Z e05882893abbd0418dd9ff166dc58eca
index 2d968f744b073c2b1ff15d9f633b2048bc2764c9..11408483ea85330fe4ec74733f2b6ae705715847 100644 (file)
@@ -1 +1 @@
-0c8b74e668b7462c5439c04993d1d7cd74210075
\ No newline at end of file
+ce07508550da858beb0bc0763c65e6d556bb0843
\ No newline at end of file
index 42c86204e3406514bc54ae077724f7ebcd3671c2..45ab6cfd8696c88198ca5121922c1895bddf2fd3 100644 (file)
@@ -14,7 +14,7 @@
 ** to version 2.8.7, all this code was combined into the vdbe.c source file.
 ** But that file was getting too big so this subroutines were split out.
 **
-** $Id: vdbeaux.c,v 1.410 2008/09/16 09:09:20 danielk1977 Exp $
+** $Id: vdbeaux.c,v 1.411 2008/09/19 18:32:27 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -761,13 +761,32 @@ void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){
 */
 static void releaseMemArray(Mem *p, int N){
   if( p && N ){
+    Mem *pEnd;
     sqlite3 *db = p->db;
     int malloc_failed = db->mallocFailed;
-    while( N-->0 ){
-      assert( N<2 || p[0].db==p[1].db );
-      sqlite3VdbeMemRelease(p);
+    for(pEnd=&p[N]; p<pEnd; p++){
+      assert( (&p[1])==pEnd || p[0].db==p[1].db );
+
+      /* This block is really an inlined version of sqlite3VdbeMemRelease()
+      ** that takes advantage of the fact that the memory cell value is 
+      ** being set to NULL after releasing any dynamic resources.
+      **
+      ** The justification for duplicating code is that according to 
+      ** callgrind, this causes a certain test case to hit the CPU 4.7 
+      ** percent less (x86 linux, gcc version 4.1.2, -O6) than if 
+      ** sqlite3MemRelease() were called from here. With -O2, this jumps
+      ** to 6.6 percent. The test case is inserting 1000 rows into a table 
+      ** with no indexes using a single prepared INSERT statement, bind() 
+      ** and reset(). Inserts are grouped into a transaction.
+      */
+      if( p->flags&(MEM_Agg|MEM_Dyn) ){
+        sqlite3VdbeMemRelease(p);
+      }else if( p->zMalloc ){
+        sqlite3DbFree(db, p->zMalloc);
+        p->zMalloc = 0;
+      }
+
       p->flags = MEM_Null;
-      p++;
     }
     db->mallocFailed = malloc_failed;
   }