mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Performance enhancements in the b-tree mutex logic.
FossilOrigin-Name: 8914530644f938a7a98e25ea1fb0bca1f9d79101
This commit is contained in:
@@ -38,7 +38,7 @@ static void lockBtreeMutex(Btree *p){
|
||||
** Release the BtShared mutex associated with B-Tree handle p and
|
||||
** clear the p->locked boolean.
|
||||
*/
|
||||
static void unlockBtreeMutex(Btree *p){
|
||||
static void SQLITE_NOINLINE unlockBtreeMutex(Btree *p){
|
||||
BtShared *pBt = p->pBt;
|
||||
assert( p->locked==1 );
|
||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||
@@ -49,6 +49,9 @@ static void unlockBtreeMutex(Btree *p){
|
||||
p->locked = 0;
|
||||
}
|
||||
|
||||
/* Forward reference */
|
||||
static void SQLITE_NOINLINE btreeLockCarefully(Btree *p);
|
||||
|
||||
/*
|
||||
** Enter a mutex on the given BTree object.
|
||||
**
|
||||
@@ -66,8 +69,6 @@ static void unlockBtreeMutex(Btree *p){
|
||||
** subsequent Btrees that desire a lock.
|
||||
*/
|
||||
void sqlite3BtreeEnter(Btree *p){
|
||||
Btree *pLater;
|
||||
|
||||
/* Some basic sanity checking on the Btree. The list of Btrees
|
||||
** connected by pNext and pPrev should be in sorted order by
|
||||
** Btree.pBt value. All elements of the list should belong to
|
||||
@@ -92,6 +93,17 @@ void sqlite3BtreeEnter(Btree *p){
|
||||
if( !p->sharable ) return;
|
||||
p->wantToLock++;
|
||||
if( p->locked ) return;
|
||||
btreeLockCarefully(p);
|
||||
}
|
||||
|
||||
/* This is a helper function for sqlite3BtreeLock(). By moving
|
||||
** complex, but seldom used logic, out of sqlite3BtreeLock() and
|
||||
** into this routine, we avoid unnecessary stack pointer changes
|
||||
** and thus help the sqlite3BtreeLock() routine to run much faster
|
||||
** in the common case.
|
||||
*/
|
||||
static void SQLITE_NOINLINE btreeLockCarefully(Btree *p){
|
||||
Btree *pLater;
|
||||
|
||||
/* In most cases, we should be able to acquire the lock we
|
||||
** want without having to go throught the ascending lock
|
||||
@@ -124,6 +136,7 @@ void sqlite3BtreeEnter(Btree *p){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Exit the recursive mutex on a Btree.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user