1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Change the size of a mini-lookaside allocation to a macro (MINI_SZ) rather

than a magic number (128).

FossilOrigin-Name: 5e1949bca998f3c8c23a8ebf01c7a2e7a2af1fdad43886271e1fe0f25411551d
This commit is contained in:
drh
2019-12-12 17:17:24 +00:00
parent 20d6c1fe1b
commit 0225d819c4
5 changed files with 19 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
C Merge\senhancements\sfrom\strunk.
D 2019-12-12T16:49:10.371
C Change\sthe\ssize\sof\sa\smini-lookaside\sallocation\sto\sa\smacro\s(MINI_SZ)\srather\nthan\sa\smagic\snumber\s(128).
D 2019-12-12T17:17:24.501
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -491,8 +491,8 @@ F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c 5de3fd62bd1a692353c8f9c7bbde658f0b579f195620ca3cde1948a53015dddd
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c d74f5e7bd51f3c9d283442473eb65aef359664efd6513591c03f01881c4ae2da
F src/main.c dc4fe09174ef0c11204ca90ed46323471c127c9d18266ec97ee1bca871200e99
F src/malloc.c 350d345ab12aa089f3dbd30b4db9b57e486c9dd920d275d1775aa5b6899199ff
F src/main.c 94bf8b6a283914cc8fa8743b3db5350206a4be5cccfd9c84d53409ca5d8bd1c1
F src/malloc.c 8a907f9e802ff517acb5e9edc13798428fd7668136456d9432a884a7fe5680f5
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3
@@ -532,7 +532,7 @@ F src/shell.c.in 4a3a9e1c11847b1904f2b01d087af1c052f660902755abab457cab1756817de
F src/sqlite.h.in 2a23e8161775253d9cf383c2c6aa559005dc787d350dcb0be67a6c4cc3bd1d19
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 72af51aa4e912e14cd495fb6e7fac65f0940db80ed950d90911aff292cc47ce2
F src/sqliteInt.h 7965727cc420b5e9ab79f4ba8bda8e806ba315c6e9f489e83f0202f3397fb522
F src/sqliteInt.h fad2ac9bc3957bd090ca979e012b744caa60529411a6ab6d379b902983f84134
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
F src/status.c 0fe55b92810509eac821ded2e177e1da944a78cdcdfec7813ad1d6b36d6d667e
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
@@ -1852,7 +1852,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P b02fdc09c838f355d9efce57f817d6a86153153b4a1f2b763914f4aaa34cb76e c6af9f655b73200ecc0c4189698e421af6ca584babdc76e73a36d468b2eea1f9
R acd8cbaefaeedad19b6643abb0f66a70
P 6cb053f99b5be2ecc30e0733d8f1e4f2a89f642656d3883fc0c867b10a87ba6b
R 795bb9e2b806be9ab8e7aa8c719a5a17
U drh
Z 68e3e8eeb067499423bb6b0f8443d732
Z 49d95eecb36c694ed8db26c3a8686826

View File

@@ -1 +1 @@
6cb053f99b5be2ecc30e0733d8f1e4f2a89f642656d3883fc0c867b10a87ba6b
5e1949bca998f3c8c23a8ebf01c7a2e7a2af1fdad43886271e1fe0f25411551d

View File

@@ -720,9 +720,9 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
db->lookaside.pMiniFree = 0;
/* The arithmetic below causes the number of large lookaside slots to be 1/3
** the number of mini slots, based on the observation that 75% of allocations
** are <=128B.
** are <= MINI_SZ bytes.
*/
cnt = szAlloc/(3*128+sz);
cnt = szAlloc/(3*MINI_SZ+sz);
#endif
db->lookaside.sz = (u16)sz;
db->lookaside.szTrue = (u16)sz;
@@ -740,11 +740,11 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
#ifndef SQLITE_OMIT_MINI_LOOKASIDE
db->lookaside.pMiddle = p;
/* Fill the remainder of the buffer with mini slots */
while(p<=(LookasideSlot*)&((u8*)pStart)[szAlloc-128]){
while(p<=(LookasideSlot*)&((u8*)pStart)[szAlloc-MINI_SZ]){
p->pNext = db->lookaside.pMiniInit;
db->lookaside.pMiniInit = p;
db->lookaside.nSlot++;
p = (LookasideSlot*)&((u8*)p)[128];
p = (LookasideSlot*)&((u8*)p)[MINI_SZ];
}
#endif
db->lookaside.pEnd = p;

View File

@@ -334,7 +334,7 @@ int sqlite3MallocSize(void *p){
}
static int lookasideMallocSize(sqlite3 *db, void *p){
#ifndef SQLITE_OMIT_MINI_LOOKASIDE
return p<db->lookaside.pMiddle ? db->lookaside.szTrue : 128;
return p<db->lookaside.pMiddle ? db->lookaside.szTrue : MINI_SZ;
#else
return db->lookaside.szTrue;
#endif
@@ -408,7 +408,7 @@ void sqlite3DbFreeNN(sqlite3 *db, void *p){
if( p>=db->lookaside.pMiddle ){
# ifdef SQLITE_DEBUG
/* Trash all content in the buffer being freed */
memset(p, 0xaa, 128);
memset(p, 0xaa, MINI_SZ);
# endif
pBuf->pNext = db->lookaside.pMiniFree;
db->lookaside.pMiniFree = pBuf;
@@ -583,7 +583,7 @@ void *sqlite3DbMallocRawNN(sqlite3 *db, u64 n){
}
db->lookaside.anStat[1]++;
# ifndef SQLITE_OMIT_MINI_LOOKASIDE
}else if( n<=128 ){
}else if( n<=MINI_SZ ){
if( (pBuf = db->lookaside.pMiniFree)!=0 ){
db->lookaside.pMiniFree = pBuf->pNext;
db->lookaside.anStat[0]++;

View File

@@ -1303,6 +1303,9 @@ struct LookasideSlot {
#define EnableLookaside db->lookaside.bDisable--;\
db->lookaside.sz=db->lookaside.bDisable?0:db->lookaside.szTrue
/* Size of the MINI lookside allocation */
#define MINI_SZ 128
/*
** A hash table for built-in function definitions. (Application-defined
** functions use a regular table table from hash.h.)