]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Reduce the average (but not maximum) size of the allocations made as part of a checkp...
authordan <dan@noemail.net>
Fri, 25 Jun 2010 16:34:32 +0000 (16:34 +0000)
committerdan <dan@noemail.net>
Fri, 25 Jun 2010 16:34:32 +0000 (16:34 +0000)
FossilOrigin-Name: 4a7fd91b7ab2c5d21fbac7f6f123820c8f4ec7f6

manifest
manifest.uuid
src/wal.c

index 9a8531a0cda96451b24a917328d67bd1a7865a32..ced8a2cef14948a8d06172c10587686f60089875 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Reduce\sthe\ssize\sof\sthe\slarge\sallocation\s(approx\s8KB\sfor\severy\s4000\sframes\sin\sthe\slog)\sthat\soccurs\sduring\scheckpoint.\sUse\sthe\s'scratch'\smemory\sfor\sthis\sallocation\sinstead\sof\sthe\sgeneral\spurpose\sallocation.
-D 2010-06-25T15:16:25
+C Reduce\sthe\saverage\s(but\snot\smaximum)\ssize\sof\sthe\sallocations\smade\sas\spart\sof\sa\scheckpoint.
+D 2010-06-25T16:34:32
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -226,7 +226,7 @@ F src/vdbeblob.c 258a6010ba7a82b72b327fb24c55790655689256
 F src/vdbemem.c 5e579abf6532001dfbee0e640dc34eae897a9807
 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
 F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda
-F src/wal.c 7f2c67f14fd3f84fb725cbfdf4df894eeee80a6d
+F src/wal.c 22522709a4eb911fa9d595f033cfa5db63e16981
 F src/wal.h 4ace25262452d17e7d3ec970c89ee17794004008
 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
 F src/where.c 1c895bef33d0dfc7ed90fb1f74120435d210ea56
@@ -825,7 +825,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P af471ed79f539ff495f6d4cb3b69188c8af7ae3d
-R 3f79fa337bc0c5c5671e54a144204fa5
+P 29887487ed549f97c3c9b37f852bae179b6ea9a9
+R 0d354ce5ca0d0be1f06510bbeac66ab5
 U dan
-Z 49c1806c3eb5e28123879bb170870e95
+Z 4ef8c49b4f2e94b4894a55fae3b39c83
index 8c14e61b740fab0bc7ff9a1d2074570c1bec880f..10328ee61f49904f53645d5999c713569337d734 100644 (file)
@@ -1 +1 @@
-29887487ed549f97c3c9b37f852bae179b6ea9a9
\ No newline at end of file
+4a7fd91b7ab2c5d21fbac7f6f123820c8f4ec7f6
\ No newline at end of file
index 62ed887f307c47b37662f2a18abac26421cf9d33..69b213dd206bfb01207a61e5968c364dbbdbe4d6 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -1425,8 +1425,8 @@ static int walIteratorInit(Wal *pWal, WalIterator **pp){
   /* Allocate space for the WalIterator object. */
   nSegment = walFramePage(iLast) + 1;
   nByte = sizeof(WalIterator) 
-        + (nSegment-1)*(sizeof(struct WalSegment))
-        + nSegment*(HASHTABLE_NPAGE * sizeof(ht_slot));
+        + (nSegment-1)*sizeof(struct WalSegment)
+        + iLast*sizeof(ht_slot);
   p = (WalIterator *)sqlite3ScratchMalloc(nByte);
   if( !p ){
     return SQLITE_NOMEM;
@@ -1437,26 +1437,29 @@ static int walIteratorInit(Wal *pWal, WalIterator **pp){
   /* Allocate temporary space used by the merge-sort routine. This block
   ** of memory will be freed before this function returns.
   */
-  aTmp = (ht_slot *)sqlite3ScratchMalloc(HASHTABLE_NPAGE * sizeof(ht_slot));
+  aTmp = (ht_slot *)sqlite3ScratchMalloc(
+      sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast)
+  );
   if( !aTmp ){
     rc = SQLITE_NOMEM;
   }
 
   for(i=0; rc==SQLITE_OK && i<nSegment; i++){
     volatile ht_slot *aHash;
-    int j;
     u32 iZero;
-    int nEntry;
     volatile u32 *aPgno;
-    ht_slot *aIndex;
 
     rc = walHashGet(pWal, i, &aHash, &aPgno, &iZero);
     if( rc==SQLITE_OK ){
+      int j;                      /* Counter variable */
+      int nEntry;                 /* Number of entries in this segment */
+      ht_slot *aIndex;            /* Sorted index for this segment */
+
       aPgno++;
       nEntry = ((i+1)==nSegment)?iLast-iZero:(u32 *)aHash-(u32 *)aPgno;
+      aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[iZero];
       iZero++;
   
-      aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[i*HASHTABLE_NPAGE];
       for(j=0; j<nEntry; j++){
         aIndex[j] = j;
       }