]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Change the definition of SQLITE_CONFIG_PAGECACHE and
authordrh <drh@noemail.net>
Thu, 31 Jul 2008 17:16:05 +0000 (17:16 +0000)
committerdrh <drh@noemail.net>
Thu, 31 Jul 2008 17:16:05 +0000 (17:16 +0000)
SQLITE_CONFIG_SCRATCH to omit the magic "+4" in the buffer size
calculation. (CVS 5512)

FossilOrigin-Name: e7ed0fe640a39053009eac52a7f055b121750e57

manifest
manifest.uuid
src/malloc.c
src/sqlite.h.in
src/test_malloc.c

index dbd4b3e173fa056de9c70218a6a652a3fa0127b1..6f0a9d5028ca9c7281ce283e61a27ab06d0f51f4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Documentation\supdates.\s(CVS\s5511)
-D 2008-07-31T14:47:55
+C Change\sthe\sdefinition\sof\sSQLITE_CONFIG_PAGECACHE\sand\nSQLITE_CONFIG_SCRATCH\sto\somit\sthe\smagic\s"+4"\sin\sthe\sbuffer\ssize\ncalculation.\s(CVS\s5512)
+D 2008-07-31T17:16:05
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in bbb62eecc851379aef5a48a1bf8787eb13e6ec06
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -116,7 +116,7 @@ F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
 F src/legacy.c 3635cc6a5889918086b3501de8287cbbecb55917
 F src/loadext.c 9ab55455f59dce0ae6388952216a1505ce7f9d13
 F src/main.c 70d285dce241ad8daa320f78b060edb73bba637e
-F src/malloc.c 9359e52a3e8519a0584d3c90335ca4a76b1d90a8
+F src/malloc.c b1a337e2b903cd78cd7e529e2706ecf1ad95473d
 F src/md5.c 008216bbb5d34c6fbab5357aa68575ad8a31516a
 F src/mem1.c 3a7fe31d8290baa3bb203af72f7dfd6323966bcd
 F src/mem2.c 87381b143530cc377592e868bd548e881c2498a3
@@ -144,7 +144,7 @@ F src/printf.c 2e984b2507291a7e16d89dc9bb60582904f6247d
 F src/random.c 5c754319d38abdd6acd74601ee0105504adc508a
 F src/select.c ef18af5624fc3189014e6b617a36562394740f91
 F src/shell.c 4b835fe734304ac22a3385868cd3790c1e4f7aa1
-F src/sqlite.h.in 1980ef5f4f36ae986f3bf1d54ee322c967b69923
+F src/sqlite.h.in 30af3a002a0b672aaae8f4a5deb0a2e9a4b699af
 F src/sqlite3ext.h 1e3887c9bd3ae66cb599e922824b04cd0d0f2c3e
 F src/sqliteInt.h a4d6bcf383b1ff207f175f7e274a83d1283c73d7
 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
@@ -168,7 +168,7 @@ F src/test_devsym.c 6012cb8e3acf812513511025a4fa5d626e0ba19b
 F src/test_func.c 94c4424ed9869ecf2e2132662a04581bbec016f6
 F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f
 F src/test_loadext.c df8ab3a6481ddebbdf0d28ebac5d9e0790f7860f
-F src/test_malloc.c 398f670f29e2d0c7b7717e2ea6386693b29afa28
+F src/test_malloc.c 43668d9cb053be59eac02f42bd0ce6aa4a5f15c6
 F src/test_md5.c 28209a4e2068711b5443c33104fe41f21d160071
 F src/test_mutex.c d3422d9f60cc1330249d102e74b333f0d24a0cb6
 F src/test_onefile.c 243157b10275251c5dc2d6619aee2ff9ae22379c
@@ -614,7 +614,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P f94239933e6f93d9780178b6f9a6b14ca791716a
-R cac4b89ea15db49a51f5d5c6e563f0a7
+P e7fdd813ccdefab33aedbcf7f44e13b935dd3299
+R 0da2bc60a3b7ef28cf0581731b3646dc
 U drh
-Z 1c663e3103bc4c56c4b3a3ae279ff2de
+Z f0ba0aa5b2784db3a79cd7c3deea3b55
index 8f6e018af07f761b6f281e095bd6328fe67a0dce..a210cacff4a9eadc5986dba8c036a02317a89f2d 100644 (file)
@@ -1 +1 @@
-e7fdd813ccdefab33aedbcf7f44e13b935dd3299
\ No newline at end of file
+e7ed0fe640a39053009eac52a7f055b121750e57
\ No newline at end of file
index c7b2e650f93d8826fc053c58f86f0028747c913d..a68378a0f8ba07d5845075cccaa74bc3a753b1a8 100644 (file)
@@ -12,7 +12,7 @@
 **
 ** Memory allocation functions used throughout sqlite.
 **
-** $Id: malloc.c,v 1.31 2008/07/29 14:29:07 drh Exp $
+** $Id: malloc.c,v 1.32 2008/07/31 17:16:05 drh Exp $
 */
 #include "sqliteInt.h"
 #include <stdarg.h>
@@ -115,6 +115,7 @@ int sqlite3MallocInit(void){
   if( sqlite3Config.pScratch && sqlite3Config.szScratch>=3000
       && sqlite3Config.nScratch>0 ){
     int i;
+    sqlite3Config.szScratch -= 4;
     mem0.aScratchFree = (u32*)&((char*)sqlite3Config.pScratch)
                   [sqlite3Config.szScratch*sqlite3Config.nScratch];
     for(i=0; i<sqlite3Config.nScratch; i++){ mem0.aScratchFree[i] = i; }
@@ -124,8 +125,13 @@ int sqlite3MallocInit(void){
     sqlite3Config.szScratch = 0;
   }
   if( sqlite3Config.pPage && sqlite3Config.szPage>=512
-      && sqlite3Config.nPage>0 ){
+      && sqlite3Config.nPage>1 ){
     int i;
+    int overhead;
+    int sz = sqlite3Config.szPage;
+    int n = sqlite3Config.nPage;
+    overhead = (4*n + sz - 1)/sz;
+    sqlite3Config.nPage -= overhead;
     mem0.aPageFree = (u32*)&((char*)sqlite3Config.pPage)
                   [sqlite3Config.szPage*sqlite3Config.nPage];
     for(i=0; i<sqlite3Config.nPage; i++){ mem0.aPageFree[i] = i; }
index ccc53e6303cd74df5dbcfd3ba41137472e21eb2e..9230be4853f94a64062940cde73ae486c5d02fbf 100644 (file)
@@ -30,7 +30,7 @@
 ** the version number) and changes its name to "sqlite3.h" as
 ** part of the build process.
 **
-** @(#) $Id: sqlite.h.in,v 1.383 2008/07/31 14:47:55 drh Exp $
+** @(#) $Id: sqlite.h.in,v 1.384 2008/07/31 17:16:05 drh Exp $
 */
 #ifndef _SQLITE3_H_
 #define _SQLITE3_H_
@@ -1109,7 +1109,7 @@ struct sqlite3_mem_methods {
 **   <li> [sqlite3_memory_used()]
 **   <li> [sqlite3_memory_highwater()]
 **   <li> [sqlite3_soft_heap_limit()]
-**   <li> sqlite3_memory_status()
+**   <li> [sqlite3_status()]
 **   </ul>
 ** </dd>
 **
@@ -1117,8 +1117,10 @@ struct sqlite3_mem_methods {
 ** <dd>This option specifies a static memory buffer that SQLite can use for
 ** scratch memory.  There are three arguments:  A pointer to the memory, the
 ** size of each scratch buffer (sz), and the number of buffers (N).  The sz
-** argument must be a multiple of 16. The first
-** argument should point to an allocation of at least (sz+4)*N bytes of memory.
+** argument must be a multiple of 16. The sz parameter should be a few bytes
+** larger than the actual scratch space required due internal overhead.
+** The first
+** argument should point to an allocation of at least sz*N bytes of memory.
 ** SQLite will use no more than one scratch buffer at once per thread, so
 ** N should be set to the expected maximum number of threads.  The sz
 ** parameter should be 6 times the size of the largest database page size.
@@ -1132,11 +1134,13 @@ struct sqlite3_mem_methods {
 ** the database page cache.  There are three arguments: A pointer to the
 ** memory, the size of each page buffer (sz), and the number of pages (N).
 ** The sz argument must be a power of two between 512 and 32768.  The first
-** argument should point to an allocation of at least (sz+4)*N bytes of memory.
+** argument should point to an allocation of at least sz*N bytes of memory.
 ** SQLite will use the memory provided by the first argument to satisfy its
 ** memory needs for the first N pages that it adds to cache.  If additional
 ** page cache memory is needed beyond what is provided by this option, then
-** SQLite goes to [sqlite3_malloc()] for the additional storage space.</dd>
+** SQLite goes to [sqlite3_malloc()] for the additional storage space.
+** The implementation might use one or more of the N buffers to hold 
+** memory accounting information. </dd>
 **
 ** <dt>SQLITE_CONFIG_HEAP</dt>
 ** <dd>This option specifies a static memory buffer that SQLite will use
@@ -6175,7 +6179,7 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
 **
 ** <dt>SQLITE_STATUS_PARSER_STACK</dt>
 ** <dd>This parameter records the deepest parser stack.  It is only
-** meaningful if SQLite is compiled with YYTRACKMAXSTACKDEPTH.</dd>
+** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>
 ** </dl>
 **
 ** New status parameters may be added from time to time.
index 9e4966dc77a670cea0b1a5d730f1cf085414c13f..63c9c046953d56bef7af6f1c00fd457ef18e158b 100644 (file)
@@ -13,7 +13,7 @@
 ** This file contains code used to implement test interfaces to the
 ** memory allocation subsystem.
 **
-** $Id: test_malloc.c,v 1.43 2008/07/29 14:29:07 drh Exp $
+** $Id: test_malloc.c,v 1.44 2008/07/31 17:16:05 drh Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -886,7 +886,7 @@ static int test_config_scratch(
     buf = 0;
     rc = sqlite3_config(SQLITE_CONFIG_SCRATCH, 0, 0, 0);
   }else{
-    buf = malloc( (sz+4)*N );
+    buf = malloc( sz*N );
     rc = sqlite3_config(SQLITE_CONFIG_SCRATCH, buf, sz, N);
   }
   pResult = Tcl_NewObj();
@@ -926,7 +926,7 @@ static int test_config_pagecache(
     buf = 0;
     rc = sqlite3_config(SQLITE_CONFIG_PAGECACHE, 0, 0, 0);
   }else{
-    buf = malloc( (sz+4)*N );
+    buf = malloc( sz*N );
     rc = sqlite3_config(SQLITE_CONFIG_PAGECACHE, buf, sz, N);
   }
   pResult = Tcl_NewObj();