diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/global.c | 10 | ||||
-rw-r--r-- | src/main.c | 40 | ||||
-rw-r--r-- | src/malloc.c | 34 | ||||
-rw-r--r-- | src/sqliteInt.h | 28 | ||||
-rw-r--r-- | src/status.c | 18 |
5 files changed, 65 insertions, 65 deletions
diff --git a/src/global.c b/src/global.c index 570002be4..4072fa0d0 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 9f541ff0d..35741ab9f 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; i<nSm; i++){ - p->pNext = 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 1074156ee..9dd400a3b 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 p<db->lookaside.pMiddle ? db->lookaside.szTrue : MINI_SZ; +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE + return p<db->lookaside.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 463cfcefc..1ed789eb7 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 977457f8e..c42bcc285 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 } |