Below is the list of changes that have just been committed into a local
5.1-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-04-06 14:15:10-04:00, jas@rowvwade. +4 -0
Add flags and code to analyze SyncObject usage.
storage/falcon/Connection.h@stripped, 2007-04-06 14:09:55-04:00, jas@rowvwade. +2 -1
Add flags and code to analyze SyncObject usage.
storage/falcon/Database.cpp@stripped, 2007-04-06 14:15:00-04:00, jas@rowvwade. +3 -0
Add flags and code to analyze SyncObject usage.
storage/falcon/SyncObject.cpp@stripped, 2007-04-06 14:15:01-04:00, jas@rowvwade. +74 -2
Add flags and code to analyze SyncObject usage.
storage/falcon/SyncObject.h@stripped, 2007-04-06 14:15:01-04:00, jas@rowvwade. +25 -12
Add flags and code to analyze SyncObject usage.
# 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.6/storage/falcon/Connection.h 2007-04-06 14:15:30 -04:00
+++ 1.7/storage/falcon/Connection.h 2007-04-06 14:15:30 -04:00
@@ -51,7 +51,8 @@
const int analyzeTables = 16;
const int analyzeCache = 32;
const int analyzeObjects = 64;
-const int analyzeSpace =128;
+const int analyzeSpace = 128;
+const int analyzeSync = 256;
const int traceBooleans = 1;
const int traceTriggers = 2;
--- 1.50/storage/falcon/Database.cpp 2007-04-06 14:15:30 -04:00
+++ 1.51/storage/falcon/Database.cpp 2007-04-06 14:15:30 -04:00
@@ -1878,6 +1878,9 @@
if (mask & analyzeCache)
dbb->cache->analyze (&stream);
+ if (mask & analyzeSync)
+ SyncObject::analyze(&stream);
+
return stream.getJString();
}
--- 1.21/storage/falcon/SyncObject.cpp 2007-04-06 14:15:30 -04:00
+++ 1.22/storage/falcon/SyncObject.cpp 2007-04-06 14:15:30 -04:00
@@ -43,9 +43,26 @@
#include "LinkedList.h"
#include "Log.h"
#include "SQLError.h"
+#include "Stream.h"
//#define STALL_THRESHOLD 1000
+
+#ifdef TRACE_SYNC_OBJECTS
+
+#define BUMP(counter) ++counter
+#define BUMP_INTERLOCKED(counter) INTERLOCKED_INCREMENT(counter)
+
+static const int MAX_SYNC_OBJECTS = 2000;
+static volatile INTERLOCK_TYPE nextSyncObjectId;
+static SyncObject *syncObjects[MAX_SYNC_OBJECTS];
+
+#else
+#define BUMP(counter)
+#define BUMP_INTERLOCKED(counter)
+#endif
+
+
/***
#ifdef _DEBUG
static char THIS_FILE[]=__FILE__;
@@ -82,19 +99,43 @@
monitorCount = 0;
stalls = 0;
exclusiveThread = NULL;
+
+#ifdef TRACE_SYNC_OBJECTS
+ sharedCount = 0;
+ exclusiveCount = 0;
+ waitCount = 0;
+ queueLength = 0;
+ where = NULL;
+ objectId = INTERLOCKED_INCREMENT(nextSyncObjectId);
+
+ if (objectId < MAX_SYNC_OBJECTS)
+ syncObjects[objectId] = this;
+#endif
}
SyncObject::~SyncObject()
{
ASSERT(lockState == 0);
+
+#ifdef TRACE_SYNC_OBJECTS
+ if (objectId < MAX_SYNC_OBJECTS)
+ syncObjects[objectId] = NULL;
+#endif
}
void SyncObject::lock(Sync *sync, LockType type)
{
Thread *thread;
+
+#ifdef TRACE_SYNC_OBJECTS
+ if (sync)
+ where = sync->where;
+#endif
if (type == Shared)
{
+ BUMP_INTERLOCKED(sharedCount);
+
for(;;)
{
int oldState = lockState;
@@ -148,6 +189,7 @@
if (thread == exclusiveThread)
{
++monitorCount;
+ BUMP(exclusiveCount);
return;
}
@@ -162,14 +204,15 @@
if (COMPARE_EXCHANGE(&lockState, oldState, -1))
{
exclusiveThread = thread;
+ BUMP(exclusiveCount);
+
return;
}
}
mutex.lock();
- //Thread *oldExclusive = exclusiveThread;
- //ASSERT(!oldExclusive || (oldExclusive->threadId != thread->threadId));
bumpWaiters(1);
+ BUMP(exclusiveCount);
while (que == NULL)
{
@@ -241,6 +284,7 @@
void SyncObject::wait(LockType type, Thread *thread, Sync *sync)
{
++stalls;
+ BUMP(waitCount);
#ifdef STALL_THRESHOLD
if ((stalls % STALL_THRESHOLD) == STALL_THRESHOLD - 1)
@@ -250,6 +294,9 @@
Thread *volatile *ptr;
for (ptr = &que; *ptr; ptr = &(*ptr)->que)
+ {
+ BUMP(queueLength);
+
if (*ptr == thread)
{
LOG_DEBUG ("Apparent single thread deadlock for thread %d (%x)\n", thread->threadId, thread);
@@ -260,6 +307,7 @@
mutex.release();
throw SQLEXCEPTION (BUG_CHECK, "Single thread deadlock");
}
+ }
thread->que = NULL;
thread->lockType = type;
@@ -496,4 +544,28 @@
thread->lockType = lockType;
thread->lockGranted = lockGranted;
thread->lockPending = lockPending;
+}
+
+void SyncObject::setWhere(const char* string)
+{
+#ifdef TRACE_SYNC_OBJECTS
+ where = string;
+#endif
+}
+
+void SyncObject::analyze(Stream* stream)
+{
+#ifdef TRACE_SYNC_OBJECTS
+ SyncObject *syncObject;
+ stream->format("Where\tShares\tExclusives\tWaits\tAverage Queue\n");
+
+ for (int n = 1; n < MAX_SYNC_OBJECTS; ++n)
+ if ( (syncObject = syncObjects[n]) && syncObject->where)
+ stream->format("%s\t%d\t%d\t%d\t%d\t\n",
+ syncObject->where,
+ syncObject->sharedCount,
+ syncObject->exclusiveCount,
+ syncObject->waitCount,
+ (syncObject->waitCount) ? syncObject->queueLength / syncObject->waitCount : 0);
+#endif
}
--- 1.5/storage/falcon/SyncObject.h 2007-04-06 14:15:30 -04:00
+++ 1.6/storage/falcon/SyncObject.h 2007-04-06 14:15:30 -04:00
@@ -40,9 +40,13 @@
#include "Mutex.h"
+#define TRACE_SYNC_OBJECTS
+
+class SyncObject;
class Sync;
class Thread;
class LinkedList;
+class Stream;
class SyncObject : public SynchronizationObject
{
@@ -54,14 +58,25 @@
void stalled(Thread *thread);
void printEvents(int level);
void postEvent (Thread *thread, const char *what, Thread *granting);
- //void print(int level);
void downGrade (LockType type);
bool isLocked();
+ void sysServiceFailed(const char* server, int code);
+ void bumpWaiters(int delta);
+ void grantLocks(void);
+ //void assertionFailed(void);
+ int getState(void);
+ void validate(LockType lockType);
+ void unlock(void);
+ bool ourExclusiveLock(void);
+ void frequentStaller(Thread *thread, Sync *sync);
+ void setWhere(const char* string);
virtual void unlock (Sync *sync, LockType type);
virtual void lock (Sync *sync, LockType type);
virtual void findLocks (LinkedList &threads, LinkedList& syncObjects);
+ static void analyze(Stream* stream);
+
inline Thread* getExclusiveThread()
{ return exclusiveThread; };
@@ -75,17 +90,15 @@
Thread *volatile exclusiveThread;
volatile int waiters;
int stalls;
-
-public:
- void sysServiceFailed(const char* server, int code);
- void bumpWaiters(int delta);
- void grantLocks(void);
- //void assertionFailed(void);
- int getState(void);
- void validate(LockType lockType);
- void unlock(void);
- bool ourExclusiveLock(void);
- void frequentStaller(Thread *thread, Sync *sync);
+
+#ifdef TRACE_SYNC_OBJECTS
+ int objectId;
+ volatile long sharedCount;
+ int exclusiveCount;
+ int waitCount;
+ int queueLength;
+ const char* where;
+#endif
};
#endif // !defined(AFX_SYNCOBJECT_H__59333A53_BC53_11D2_AB5E_0000C01D2301__INCLUDED_)
| Thread |
|---|
| • bk commit into 5.1-falcon tree (jas:1.2561) | U-ROWVWADEjas | 6 Apr |