Below is the list of changes that have just been committed into a local
6.0-falcon repository of . When does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-07-06 10:20:14-04:00, jas@rowvwade. +1 -0
Optimized SyncObject.
storage/falcon/SyncObject.cpp@stripped, 2007-07-06 10:19:56-04:00, jas@rowvwade. +51 -26
Optimized SyncObject.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: jas
# Host: rowvwade.
# Root: D:/MySQL/mysql-5.1-falcon
--- 1.33/storage/falcon/SyncObject.cpp 2007-07-06 10:20:36 -04:00
+++ 1.34/storage/falcon/SyncObject.cpp 2007-07-06 10:20:36 -04:00
@@ -48,6 +48,11 @@
//#define STALL_THRESHOLD 1000
+#define BACKOFF \
+ if (thread)\
+ thread->sleep(1);\
+ else\
+ thread = Thread::getThread("SyncObject::lock")
#ifdef TRACE_SYNC_OBJECTS
@@ -150,10 +155,7 @@
if (COMPARE_EXCHANGE(&lockState, oldState, newState))
return;
- if (thread)
- thread->sleep(1);
- else
- thread = Thread::getThread("SyncObject::lock");
+ BACKOFF;
}
mutex.lock();
@@ -176,10 +178,7 @@
return;
}
- if (thread)
- thread->sleep(1);
- else
- thread = Thread::getThread("SyncObject::lock");
+ BACKOFF;
}
thread = Thread::getThread("SyncObject::lock");
@@ -221,10 +220,7 @@
return;
}
- if (thread)
- thread->sleep(1);
- else
- thread = Thread::getThread("SyncObject::lock");
+ BACKOFF;
}
mutex.lock();
@@ -247,10 +243,7 @@
return;
}
- if (thread)
- thread->sleep(1);
- else
- thread = Thread::getThread("SyncObject::lock");
+ BACKOFF;
}
}
@@ -268,7 +261,8 @@
return;
}
-
+
+ /***
Thread *thread = NULL;
for (;;)
@@ -291,6 +285,23 @@
else
thread = Thread::getThread("SyncObject::lock");
}
+ ***/
+
+ exclusiveThread = NULL;
+
+ if (type == Shared)
+ {
+ ASSERT(lockState > 0);
+ INTERLOCKED_DECREMENT(lockState);
+ }
+ else
+ {
+ ASSERT(lockState == -1);
+ INTERLOCKED_INCREMENT(lockState);
+ }
+
+ if (waiters)
+ grantLocks();
}
void SyncObject::downGrade(LockType type)
@@ -302,6 +313,8 @@
for (;;)
if (COMPARE_EXCHANGE(&lockState, -1, 1))
{
+ exclusiveThread = NULL;
+
if (waiters)
grantLocks();
@@ -431,14 +444,19 @@
void SyncObject::bumpWaiters(int delta)
{
- for (;;)
- {
- INTERLOCK_TYPE oldValue = waiters;
- INTERLOCK_TYPE newValue = waiters + delta;
-
- if (COMPARE_EXCHANGE(&waiters, oldValue, newValue))
- return;
- }
+ if (delta == 1)
+ INTERLOCKED_INCREMENT(waiters);
+ else if (delta == -1)
+ INTERLOCKED_DECREMENT(waiters);
+ else
+ for (;;)
+ {
+ INTERLOCK_TYPE oldValue = waiters;
+ INTERLOCK_TYPE newValue = waiters + delta;
+
+ if (COMPARE_EXCHANGE(&waiters, oldValue, newValue))
+ return;
+ }
}
void SyncObject::grantLocks(void)
@@ -446,7 +464,8 @@
mutex.lock();
ASSERT ((waiters && que) || (!waiters && !que));
const char *description = NULL;
-
+ Thread *thread = NULL;
+
for (Thread *thread = que, *prior = NULL, *next; thread; thread = next)
{
description = thread->description;
@@ -464,18 +483,24 @@
exclusiveThread = NULL;
break;
}
+
+ BACKOFF;
}
else
{
ASSERT(thread->lockType == Exclusive);
while (lockState == 0)
+ {
if (COMPARE_EXCHANGE(&lockState, 0, -1))
{
granted = true;
exclusiveThread = thread;
break;
}
+
+ BACKOFF;
+ }
}
if (granted)
| Thread |
|---|
| • bk commit into 6.0-falcon tree (jas:1.2592) | U-ROWVWADEjas | 6 Jul |