From cf014f6cbd2452abb29b3bef2b3b4e63e59c09f8 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Dec 2019 15:12:34 +0000 Subject: [PATCH] Refactor names. Use "small" instead of "mini" to describe the smaller of the two lookaside memory allocation sizes. FossilOrigin-Name: 88d244983854cdc1a369c5df09ae00f1098784db768ba4e17b963d187dcb1009 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/global.c | 10 +++++----- src/main.c | 40 ++++++++++++++++++++-------------------- src/malloc.c | 34 +++++++++++++++++----------------- src/sqliteInt.h | 28 ++++++++++++++-------------- src/status.c | 18 +++++++++--------- 7 files changed, 76 insertions(+), 76 deletions(-) diff --git a/manifest b/manifest index d7ccb2fbc8..afb4de68b3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\srecent\senhancements\sfrom\strunk. -D 2019-12-31T14:49:10.816 +C Refactor\snames.\s\sUse\s"small"\sinstead\sof\s"mini"\sto\sdescribe\sthe\ssmaller\nof\sthe\stwo\slookaside\smemory\sallocation\ssizes. +D 2019-12-31T15:12:34.090 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -484,7 +484,7 @@ F src/expr.c 8d4b6ac02f69e60b185cba0e38a76ba3f6f2122ee767e7de0f933fddec423e4a F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 92a248ec0fa4ed8ab60c98d9b188ce173aaf218f32e7737ba77deb2a684f9847 F src/func.c ed33e38cd642058182a31a3f518f2e34f4bbe53aa483335705c153c4d3e50b12 -F src/global.c 76da82a621fed40105172969f1a4af93bdab107fa07426f532502c498cf81eb8 +F src/global.c 89e36838a355f99cf86b118c3d4078fc3fc95cc9f992cbd70b422da8bfdf1789 F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19 F src/hash.h 9d56a9079d523b648774c1784b74b89bd93fac7b365210157482e4319a468f38 F src/hwtime.h cb1d7e3e1ed94b7aa6fde95ae2c2daccc3df826be26fc9ed7fd90d1750ae6144 @@ -492,8 +492,8 @@ F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c e43c6475b302d094ffa01d76b784c719001c9cf24c0b5af96b78e5b25dc54b83 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c d74f5e7bd51f3c9d283442473eb65aef359664efd6513591c03f01881c4ae2da -F src/main.c 34d73303ac76015d3c8961f16d49ab44a56cbc998f178b27ca07847db4cf9273 -F src/malloc.c d74d986f91ebd6a4a9b2995467f4c13a1fdb57ac87df5bb0a7fa3afe1db72d1d +F src/main.c e9e8da06e089933c3151951be34ac7212212dd8d1551f1d84a2f4416e7af56e0 +F src/malloc.c eaa4dc9602ce28b077f7de2eb275db2be270c5cc56d7fec5466301bd9b80e2f5 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 @@ -533,9 +533,9 @@ F src/shell.c.in 4a3a9e1c11847b1904f2b01d087af1c052f660902755abab457cab1756817de F src/sqlite.h.in 51f69c62ba3e980aca1e39badcaf9ad13f008774fe1bb8e7f57e3e456c656670 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 72af51aa4e912e14cd495fb6e7fac65f0940db80ed950d90911aff292cc47ce2 -F src/sqliteInt.h b5784a17e5ad158a759b2ed0a0d2ded1e1c3e9cf4cf51e4da21783790b9d0567 +F src/sqliteInt.h edc69ef8684086e8c195f969e47173ad960a0eb3f6298222b635e2ad3e0c1f98 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b -F src/status.c baf38f521ac079be616dab1ff13f60c6ce0703c7f0429a65238c695197a56935 +F src/status.c 9ff2210207c6c3b4d9631a8241a7d45ab1b26a0e9c84cb07a9b5ce2de9a3b278 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 F src/tclsqlite.c 8cd2600e8de23dff6cdf84d39f46ca57139b061b28f6f80b166bace17d52ab1c F src/test1.c c654981c1d86ebc90dd23fcc0969e6c85e28112f0acc2e2224a97a2a33e7c42f @@ -1853,7 +1853,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 47b71a84d1262c4bf6ad4f4a91820fd63593f08ae9efa144199d44972225e073 1dc83c5d54ca2890112e735e336c209adb8d067d2f647e9f8ae5d58f84a52461 -R 8dbc460e590e85bbe19d4191ea7ea91a +P 39d55579376906f212271ce9b2d367e3ad029fb173f22c7253312b467970208a +R c6267a3dfb8286b9a7bf015a7e8fc93b U drh -Z ac3eece56ae65a72ceccf8b58e31752f +Z 457f22be9b5a945c48c466bed56b269c diff --git a/manifest.uuid b/manifest.uuid index 47ee9f350b..2ca43abc99 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -39d55579376906f212271ce9b2d367e3ad029fb173f22c7253312b467970208a \ No newline at end of file +88d244983854cdc1a369c5df09ae00f1098784db768ba4e17b963d187dcb1009 \ No newline at end of file diff --git a/src/global.c b/src/global.c index 570002be4d..4072fa0d07 100644 --- a/src/global.c +++ b/src/global.c @@ -191,13 +191,13 @@ const unsigned char sqlite3CtypeMap[256] = { ** or at run-time for an individual database connection using ** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE); ** -** With the mini-lookaside enhancement, must less lookaside is required. -** The default configuration of 1200,40 actually proves 30 1200-byte slots -** and 93 128-byte slots, which is more lookaside slots that are available -** using the older 1200,100 configuration without mini-lookaside. +** With the two-size-lookaside enhancement, less lookaside is required. +** The default configuration of 1200,40 actually provides 30 1200-byte slots +** and 93 128-byte slots, which is more lookaside than is available +** using the older 1200,100 configuration without two-size-lookaside. */ #ifndef SQLITE_DEFAULT_LOOKASIDE -# ifdef SQLITE_OMIT_MINI_LOOKASIDE +# ifdef SQLITE_OMIT_TWOSIZE_LOOKASIDE # define SQLITE_DEFAULT_LOOKASIDE 1200,100 /* 120KB of memory */ # else # define SQLITE_DEFAULT_LOOKASIDE 1200,40 /* 48KB of memory */ diff --git a/src/main.c b/src/main.c index 9f541ff0d0..35741ab9f9 100644 --- a/src/main.c +++ b/src/main.c @@ -685,7 +685,7 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ void *pStart; sqlite3_int64 szAlloc = sz*(sqlite3_int64)cnt; int nBig; /* Number of full-size slots */ - int nSm; /* Number smaller mini-slots */ + int nSm; /* Number smaller LOOKASIDE_SMALL-byte slots */ if( sqlite3LookasideUsed(db,0)>0 ){ return SQLITE_BUSY; @@ -714,15 +714,15 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ }else{ pStart = pBuf; } -#ifndef SQLITE_OMIT_MINI_LOOKASIDE - if( sz>=MINI_SZ*3 ){ - nBig = szAlloc/(3*MINI_SZ+sz); - nSm = (szAlloc - sz*nBig)/MINI_SZ; - }else if( sz>=MINI_SZ*2 ){ - nBig = szAlloc/(MINI_SZ+sz); - nSm = (szAlloc - sz*nBig)/MINI_SZ; +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE + if( sz>=LOOKASIDE_SMALL*3 ){ + nBig = szAlloc/(3*LOOKASIDE_SMALL+sz); + nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL; + }else if( sz>=LOOKASIDE_SMALL*2 ){ + nBig = szAlloc/(LOOKASIDE_SMALL+sz); + nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL; }else -#endif /* SQLITE_OMIT_MINI_LOOKASIDE */ +#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ if( sz>0 ){ nBig = szAlloc/sz; nSm = 0; @@ -744,16 +744,16 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ db->lookaside.pInit = p; p = (LookasideSlot*)&((u8*)p)[sz]; } -#ifndef SQLITE_OMIT_MINI_LOOKASIDE - db->lookaside.pMiniInit = 0; - db->lookaside.pMiniFree = 0; +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE + db->lookaside.pSmallInit = 0; + db->lookaside.pSmallFree = 0; db->lookaside.pMiddle = p; for(i=0; ipNext = db->lookaside.pMiniInit; - db->lookaside.pMiniInit = p; - p = (LookasideSlot*)&((u8*)p)[MINI_SZ]; + p->pNext = db->lookaside.pSmallInit; + db->lookaside.pSmallInit = p; + p = (LookasideSlot*)&((u8*)p)[LOOKASIDE_SMALL]; } -#endif /* SQLITE_OMIT_MINI_LOOKASIDE */ +#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ assert( ((uptr)p)<=szAlloc + (uptr)pStart ); db->lookaside.pEnd = p; db->lookaside.bDisable = 0; @@ -761,11 +761,11 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ db->lookaside.nSlot = nBig+nSm; }else{ db->lookaside.pStart = db; -#ifndef SQLITE_OMIT_MINI_LOOKASIDE - db->lookaside.pMiniInit = 0; - db->lookaside.pMiniFree = 0; +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE + db->lookaside.pSmallInit = 0; + db->lookaside.pSmallFree = 0; db->lookaside.pMiddle = db; -#endif /* SQLITE_OMIT_MINI_LOOKASIDE */ +#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ db->lookaside.pEnd = db; db->lookaside.bDisable = 1; db->lookaside.sz = 0; diff --git a/src/malloc.c b/src/malloc.c index 1074156eec..9dd400a3ba 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -333,8 +333,8 @@ int sqlite3MallocSize(void *p){ return sqlite3GlobalConfig.m.xSize(p); } static int lookasideMallocSize(sqlite3 *db, void *p){ -#ifndef SQLITE_OMIT_MINI_LOOKASIDE - return plookaside.pMiddle ? db->lookaside.szTrue : MINI_SZ; +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE + return plookaside.pMiddle ? db->lookaside.szTrue : LOOKASIDE_SMALL; #else return db->lookaside.szTrue; #endif @@ -354,10 +354,10 @@ int sqlite3DbMallocSize(sqlite3 *db, void *p){ #endif if( db ){ if( ((uptr)p)<(uptr)(db->lookaside.pEnd) ){ -#ifndef SQLITE_OMIT_MINI_LOOKASIDE +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE if( ((uptr)p)>=(uptr)(db->lookaside.pMiddle) ){ assert( sqlite3_mutex_held(db->mutex) ); - return MINI_SZ; + return LOOKASIDE_SMALL; } #endif if( ((uptr)p)>=(uptr)(db->lookaside.pStart) ){ @@ -414,17 +414,17 @@ void sqlite3DbFreeNN(sqlite3 *db, void *p){ return; } if( ((uptr)p)<(uptr)(db->lookaside.pEnd) ){ -#ifndef SQLITE_OMIT_MINI_LOOKASIDE +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE if( ((uptr)p)>=(uptr)(db->lookaside.pMiddle) ){ LookasideSlot *pBuf = (LookasideSlot*)p; #ifdef SQLITE_DEBUG - memset(p, 0xaa, MINI_SZ); /* Trash freed content */ + memset(p, 0xaa, LOOKASIDE_SMALL); /* Trash freed content */ #endif - pBuf->pNext = db->lookaside.pMiniFree; - db->lookaside.pMiniFree = pBuf; + pBuf->pNext = db->lookaside.pSmallFree; + db->lookaside.pSmallFree = pBuf; return; } -#endif /* SQLITE_OMIT_MINI_LOOKASIDE */ +#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ if( ((uptr)p)>=(uptr)(db->lookaside.pStart) ){ LookasideSlot *pBuf = (LookasideSlot*)p; #ifdef SQLITE_DEBUG @@ -597,14 +597,14 @@ void *sqlite3DbMallocRawNN(sqlite3 *db, u64 n){ } return dbMallocRawFinish(db, n); } -#ifndef SQLITE_OMIT_MINI_LOOKASIDE - if( n<=MINI_SZ ){ - if( (pBuf = db->lookaside.pMiniFree)!=0 ){ - db->lookaside.pMiniFree = pBuf->pNext; +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE + if( n<=LOOKASIDE_SMALL ){ + if( (pBuf = db->lookaside.pSmallFree)!=0 ){ + db->lookaside.pSmallFree = pBuf->pNext; db->lookaside.anStat[0]++; return (void*)pBuf; - }else if( (pBuf = db->lookaside.pMiniInit)!=0 ){ - db->lookaside.pMiniInit = pBuf->pNext; + }else if( (pBuf = db->lookaside.pSmallInit)!=0 ){ + db->lookaside.pSmallInit = pBuf->pNext; db->lookaside.anStat[0]++; return (void*)pBuf; } @@ -644,9 +644,9 @@ void *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){ if( p==0 ) return sqlite3DbMallocRawNN(db, n); assert( sqlite3_mutex_held(db->mutex) ); if( ((uptr)p)<(uptr)db->lookaside.pEnd ){ -#ifndef SQLITE_OMIT_MINI_LOOKASIDE +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE if( ((uptr)p)>=(uptr)db->lookaside.pMiddle ){ - if( n<=MINI_SZ ) return p; + if( n<=LOOKASIDE_SMALL ) return p; }else #endif if( ((uptr)p)>=(uptr)db->lookaside.pStart ){ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 463cfcefc5..1ed789eb7f 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1305,17 +1305,17 @@ struct Schema { ** outstanding at any point in the past - by subtracting the number of ** allocations on the pInit list from the total number of allocations. ** -** Enhancement on 2019-12-12: Mini-lookaside +** Enhancement on 2019-12-12: Two-size-lookaside ** The default lookaside configuration is 100 slots of 1200 bytes each. ** The larger slot sizes are important for performance, but they waste ** a lot of space, as most lookaside allocations are less than 128 bytes. -** The mini-lookaside enhancement breaks up the lookaside allocation into -** two pools: One of 128-byte slots and the other of the default size -** (1200-byte) slots. Allocations are filled from the mini-pool first, +** The two-size-lookaside enhancement breaks up the lookaside allocation +** into two pools: One of 128-byte slots and the other of the default size +** (1200-byte) slots. Allocations are filled from the small-pool first, ** failing over to the full-size pool if that does not work. Thus more ** lookaside slots are available while also using less memory. ** This enhancement can be omitted by compiling with -** SQLITE_OMIT_MINI_LOOKASIDE. +** SQLITE_OMIT_TWOSIZE_LOOKASIDE. */ struct Lookaside { u32 bDisable; /* Only operate the lookaside when zero */ @@ -1326,12 +1326,12 @@ struct Lookaside { u32 anStat[3]; /* 0: hits. 1: size misses. 2: full misses */ LookasideSlot *pInit; /* List of buffers not previously used */ LookasideSlot *pFree; /* List of available buffers */ -#ifndef SQLITE_OMIT_MINI_LOOKASIDE - LookasideSlot *pMiniInit; /* List of mini buffers not prediously used */ - LookasideSlot *pMiniFree; /* List of available mini buffers */ +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE + LookasideSlot *pSmallInit; /* List of small buffers not prediously used */ + LookasideSlot *pSmallFree; /* List of available small buffers */ void *pMiddle; /* First byte past end of full-size buffers and - ** the first byte of mini-buffers */ -#endif /* SQLITE_OMIT_MINI_LOOKASIDE */ + ** the first byte of LOOKASIDE_SMALL buffers */ +#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ void *pStart; /* First byte of available memory space */ void *pEnd; /* First byte past end of available space */ }; @@ -1343,11 +1343,11 @@ struct LookasideSlot { #define EnableLookaside db->lookaside.bDisable--;\ db->lookaside.sz=db->lookaside.bDisable?0:db->lookaside.szTrue -/* Size of the MINI lookside allocation */ -#ifdef SQLITE_OMIT_MINI_LOOKASIDE -# define MINI_SZ 0 +/* Size of the smaller allocations in two-size lookside */ +#ifdef SQLITE_OMIT_TWOSIZE_LOOKASIDE +# define LOOKASIDE_SMALL 0 #else -# define MINI_SZ 128 +# define LOOKASIDE_SMALL 128 #endif /* diff --git a/src/status.c b/src/status.c index 977457f8e3..c42bcc2856 100644 --- a/src/status.c +++ b/src/status.c @@ -188,10 +188,10 @@ static u32 countLookasideSlots(LookasideSlot *p){ int sqlite3LookasideUsed(sqlite3 *db, int *pHighwater){ u32 nInit = countLookasideSlots(db->lookaside.pInit); u32 nFree = countLookasideSlots(db->lookaside.pFree); -#ifndef SQLITE_OMIT_MINI_LOOKASIDE - nInit += countLookasideSlots(db->lookaside.pMiniInit); - nFree += countLookasideSlots(db->lookaside.pMiniFree); -#endif /* SQLITE_OMIT_MINI_LOOKASIDE */ +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE + nInit += countLookasideSlots(db->lookaside.pSmallInit); + nFree += countLookasideSlots(db->lookaside.pSmallFree); +#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ if( pHighwater ) *pHighwater = db->lookaside.nSlot - nInit; return db->lookaside.nSlot - (nInit+nFree); } @@ -224,13 +224,13 @@ int sqlite3_db_status( db->lookaside.pInit = db->lookaside.pFree; db->lookaside.pFree = 0; } -#ifndef SQLITE_OMIT_MINI_LOOKASIDE - p = db->lookaside.pMiniFree; +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE + p = db->lookaside.pSmallFree; if( p ){ while( p->pNext ) p = p->pNext; - p->pNext = db->lookaside.pMiniInit; - db->lookaside.pMiniInit = db->lookaside.pMiniFree; - db->lookaside.pMiniFree = 0; + p->pNext = db->lookaside.pSmallInit; + db->lookaside.pSmallInit = db->lookaside.pSmallFree; + db->lookaside.pSmallFree = 0; } #endif }