Changeset: 68ab398acb08 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=68ab398acb08
Modified Files:
        gdk/gdk_system.c
        gdk/gdk_system.h
Branch: Oct2014
Log Message:

Don't sleep so long on long lasting lock contention; small change to lock 
statistics.


diffs (62 lines):

diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -101,11 +101,11 @@ sortlocklist(MT_Lock *l)
         * start of unprocessed part of left and right lists */
        t = ll = NULL;
        while (l && r) {
-               if (l->contention < r->contention ||
-                   (l->contention == r->contention &&
-                    l->sleep < r->sleep) ||
-                   (l->contention == r->contention &&
-                    l->sleep == r->sleep &&
+               if (l->sleep < r->sleep ||
+                   (l->sleep == r->sleep &&
+                    l->contention < r->contention) ||
+                   (l->sleep == r->sleep &&
+                    l->contention == r->contention &&
                     l->count <= r->count)) {
                        /* l is smaller */
                        if (ll == NULL) {
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -223,16 +223,13 @@ gdk_export ATOMIC_TYPE volatile GDKlocks
        do {                                                            \
                TEMDEBUG fprintf(stderr, "#lock %s contention in %s\n", 
(l)->name, n); \
                (void) ATOMIC_INC(GDKlockcontentioncnt, dummy, n);      \
+               (l)->contention++;                                      \
        } while (0)
 #define _DBG_LOCK_SLEEP(l, n)                                          \
        do {                                                            \
                if (_spincnt == 1024)                                   \
                        (void) ATOMIC_INC(GDKlocksleepcnt, dummy, n);   \
-       } while (0)
-#define _DBG_LOCK_COUNT_1(l)                   \
-       do {                                    \
-               (l)->contention++;              \
-               (l)->sleep += _spincnt >= 1024; \
+               (l)->sleep++;                                           \
        } while (0)
 #define _DBG_LOCK_COUNT_2(l)                                           \
        do {                                                            \
@@ -295,7 +292,6 @@ gdk_export ATOMIC_TYPE volatile GDKlocks
 #define _DBG_LOCK_COUNT_0(l, n)                ((void) (n))
 #define _DBG_LOCK_CONTENTION(l, n)     ((void) (n))
 #define _DBG_LOCK_SLEEP(l, n)          ((void) (n))
-#define _DBG_LOCK_COUNT_1(l)           ((void) 0)
 #define _DBG_LOCK_COUNT_2(l)           ((void) 0)
 #define _DBG_LOCK_INIT(l, n)           ((void) (n))
 #define _DBG_LOCK_DESTROY(l)           ((void) 0)
@@ -313,10 +309,9 @@ gdk_export ATOMIC_TYPE volatile GDKlocks
                        do {                                            \
                                if (++_spincnt >= 1024) {               \
                                        _DBG_LOCK_SLEEP(l, n);          \
-                                       MT_sleep_ms(_spincnt >> 10);    \
+                                       MT_sleep_ms(1);                 \
                                }                                       \
                        } while (ATOMIC_TAS((l)->lock, dummy, n) != 0); \
-                       _DBG_LOCK_COUNT_1(l);                           \
                }                                                       \
                _DBG_LOCK_LOCKER(l, n);                                 \
                _DBG_LOCK_COUNT_2(l);                                   \
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to