Index: third_party/sqlite/src/src/btmutex.c |
diff --git a/third_party/sqlite/src/src/btmutex.c b/third_party/sqlite/src/src/btmutex.c |
index d87d4d5feeb6307aecdc9a83111489ab30c678c3..f9fe5b3dde03c726191d361252bf29d724b1f50a 100644 |
--- a/third_party/sqlite/src/src/btmutex.c |
+++ b/third_party/sqlite/src/src/btmutex.c |
@@ -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,9 +93,20 @@ 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 |
+ ** want without having to go through the ascending lock |
** procedure that follows. Just be sure not to block. |
*/ |
if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){ |
@@ -124,6 +136,7 @@ void sqlite3BtreeEnter(Btree *p){ |
} |
} |
+ |
/* |
** Exit the recursive mutex on a Btree. |
*/ |