Avoid unnecessary mutex usage in pcache1, for a significant speedup.
FossilOrigin-Name: dcf4fb8d764611de60afea27cda0a8548ba7ca82
This commit is contained in:
parent
55a46c9b0e
commit
982215a2c5
15
manifest
15
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sa\sfast-path\simplementation\sof\spcache1Fetch()\sfor\sthe\scommon\scase\sof\nseparate\scaches\sthat\sdo\snot\suse\sa\smutex.
|
||||
D 2015-06-12T13:49:26.780
|
||||
C Avoid\sunnecessary\smutex\susage\sin\spcache1,\sfor\sa\ssignificant\sspeedup.
|
||||
D 2015-06-13T11:10:55.570
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 1063c58075b7400d93326b0eb332b48a54f53025
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -242,7 +242,7 @@ F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77
|
||||
F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8
|
||||
F src/pcache.c 10539fb959849ad6efff80050541cab3d25089d4
|
||||
F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8
|
||||
F src/pcache1.c 0324126d981c6db4ba39e0a6b2bf79b690d3107f
|
||||
F src/pcache1.c 7ca0caf7ec16c365aff3ddb4a7e00734a0e1fe97
|
||||
F src/pragma.c c1f4d012ea9f6b1ce52d341b2cd0ad72d560afd7
|
||||
F src/pragma.h b8632d7cdda7b25323fa580e3e558a4f0d4502cc
|
||||
F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1
|
||||
@ -1286,10 +1286,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 2e8ad2ead9d146e312c693d9b967bbd5b92429d9
|
||||
R 911300e4b1697824e69cfe439e19a5f8
|
||||
T *branch * faster-pcache1-fetch
|
||||
T *sym-faster-pcache1-fetch *
|
||||
T -sym-trunk *
|
||||
P 760700edb3ff1f5d6bf3058f874cc8e2808905c7
|
||||
R caec30587447e9722ed3cdf5357476d2
|
||||
U drh
|
||||
Z e8ae5ddb4580a5169c907c35e69dd177
|
||||
Z 153683ea51b205873f976242b39879f7
|
||||
|
@ -1 +1 @@
|
||||
760700edb3ff1f5d6bf3058f874cc8e2808905c7
|
||||
dcf4fb8d764611de60afea27cda0a8548ba7ca82
|
@ -148,8 +148,15 @@ static SQLITE_WSD struct PCacheGlobal {
|
||||
/*
|
||||
** Macros to enter and leave the PCache LRU mutex.
|
||||
*/
|
||||
#define pcache1EnterMutex(X) sqlite3_mutex_enter((X)->mutex)
|
||||
#define pcache1LeaveMutex(X) sqlite3_mutex_leave((X)->mutex)
|
||||
#if !defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) || SQLITE_THREADSAFE==0
|
||||
# define pcache1EnterMutex(X) assert((X)->mutex==0)
|
||||
# define pcache1LeaveMutex(X) assert((X)->mutex==0)
|
||||
# define PCACHE1_MIGHT_USE_GROUP_MUTEX 0
|
||||
#else
|
||||
# define pcache1EnterMutex(X) sqlite3_mutex_enter((X)->mutex)
|
||||
# define pcache1LeaveMutex(X) sqlite3_mutex_leave((X)->mutex)
|
||||
# define PCACHE1_MIGHT_USE_GROUP_MUTEX 1
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
/******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/
|
||||
@ -529,10 +536,12 @@ static int pcache1Init(void *NotUsed){
|
||||
UNUSED_PARAMETER(NotUsed);
|
||||
assert( pcache1.isInit==0 );
|
||||
memset(&pcache1, 0, sizeof(pcache1));
|
||||
#if SQLITE_THREADSAFE
|
||||
if( sqlite3GlobalConfig.bCoreMutex ){
|
||||
pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU);
|
||||
pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM);
|
||||
}
|
||||
#endif
|
||||
pcache1.grp.mxPinned = 10;
|
||||
pcache1.isInit = 1;
|
||||
return SQLITE_OK;
|
||||
@ -836,6 +845,7 @@ static PgHdr1 *pcache1FetchNoMutex(
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#if PCACHE1_MIGHT_USE_GROUP_MUTEX
|
||||
static PgHdr1 *pcache1FetchWithMutex(
|
||||
sqlite3_pcache *p,
|
||||
unsigned int iKey,
|
||||
@ -850,12 +860,15 @@ static PgHdr1 *pcache1FetchWithMutex(
|
||||
pcache1LeaveMutex(pCache->pGroup);
|
||||
return pPage;
|
||||
}
|
||||
#endif
|
||||
static sqlite3_pcache_page *pcache1Fetch(
|
||||
sqlite3_pcache *p,
|
||||
unsigned int iKey,
|
||||
int createFlag
|
||||
){
|
||||
#if PCACHE1_MIGHT_USE_GROUP_MUTEX || defined(SQLITE_DEBUG)
|
||||
PCache1 *pCache = (PCache1 *)p;
|
||||
#endif
|
||||
|
||||
assert( offsetof(PgHdr1,page)==0 );
|
||||
assert( pCache->bPurgeable || createFlag!=1 );
|
||||
@ -863,9 +876,12 @@ static sqlite3_pcache_page *pcache1Fetch(
|
||||
assert( pCache->bPurgeable==0 || pCache->nMin==10 );
|
||||
assert( pCache->nMin==0 || pCache->bPurgeable );
|
||||
assert( pCache->nHash>0 );
|
||||
#if PCACHE1_MIGHT_USE_GROUP_MUTEX
|
||||
if( pCache->pGroup->mutex ){
|
||||
return (sqlite3_pcache_page*)pcache1FetchWithMutex(p, iKey, createFlag);
|
||||
}else{
|
||||
}else
|
||||
#endif
|
||||
{
|
||||
return (sqlite3_pcache_page*)pcache1FetchNoMutex(p, iKey, createFlag);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user