Changeset: 6585c87dc839 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6585c87dc839
Modified Files:
        monetdb5/mal/mal_resource.c
        monetdb5/mal/mal_scenario.c
Branch: default
Log Message:

Use private locks in MALadmission and getFreeScenario.
This reduces lock contention significantly (don't use mal_contextLock
for everything).


diffs (97 lines):

diff --git a/monetdb5/mal/mal_resource.c b/monetdb5/mal/mal_resource.c
--- a/monetdb5/mal/mal_resource.c
+++ b/monetdb5/mal/mal_resource.c
@@ -124,6 +124,8 @@ getMemoryClaim(MalBlkPtr mb, MalStkPtr s
  * The hotclaim is a hint how large the result would be.
  */
 #ifdef USE_MAL_ADMISSION
+static MT_Lock admissionLock MT_LOCK_INITIALIZER("admissionLock");
+
 /* experiments on sf-100 on small machine showed no real improvement */
 int
 MALadmission(lng argclaim, lng hotclaim)
@@ -132,7 +134,7 @@ MALadmission(lng argclaim, lng hotclaim)
        if (argclaim == 0)
                return 0;
 
-       MT_lock_set(&mal_contextLock, "DFLOWdelay");
+       MT_lock_set(&admissionLock, "MALadmission");
        if (memoryclaims < 0)
                memoryclaims = 0;
        if (memorypool <= 0 && memoryclaims == 0)
@@ -145,12 +147,12 @@ MALadmission(lng argclaim, lng hotclaim)
                        PARDEBUG
                        mnstr_printf(GDKstdout, "#DFLOWadmit %3d thread %d pool 
" LLFMT "claims " LLFMT "," LLFMT "\n",
                                                 memoryclaims, THRgettid(), 
memorypool, argclaim, hotclaim);
-                       MT_lock_unset(&mal_contextLock, "DFLOWdelay");
+                       MT_lock_unset(&admissionLock, "MALadmission");
                        return 0;
                }
                PARDEBUG
                mnstr_printf(GDKstdout, "#Delayed due to lack of memory " LLFMT 
" requested " LLFMT " memoryclaims %d\n", memorypool, argclaim + hotclaim, 
memoryclaims);
-               MT_lock_unset(&mal_contextLock, "DFLOWdelay");
+               MT_lock_unset(&admissionLock, "MALadmission");
                return -1;
        }
        /* release memory claimed before */
@@ -159,7 +161,7 @@ MALadmission(lng argclaim, lng hotclaim)
        PARDEBUG
        mnstr_printf(GDKstdout, "#DFLOWadmit %3d thread %d pool " LLFMT " 
claims " LLFMT "," LLFMT "\n",
                                 memoryclaims, THRgettid(), memorypool, 
argclaim, hotclaim);
-       MT_lock_unset(&mal_contextLock, "DFLOWdelay");
+       MT_lock_unset(&admissionLock, "MALadmission");
        return 0;
 }
 #endif
@@ -224,9 +226,10 @@ MALresourceFairness(lng usec)
 void
 initResource(void)
 {
-#ifdef ATOMIC_LOCK
 #ifdef NEED_MT_LOCK_INIT
        ATOMIC_INIT(runningLock, "runningLock");
+#ifdef USE_MAL_ADMISSION
+       MT_lock_init(&admissionLock, "admissionLock");
 #endif
 #endif
        running = (ATOMIC_TYPE) GDKnr_threads;
diff --git a/monetdb5/mal/mal_scenario.c b/monetdb5/mal/mal_scenario.c
--- a/monetdb5/mal/mal_scenario.c
+++ b/monetdb5/mal/mal_scenario.c
@@ -144,6 +144,7 @@ static struct SCENARIO scenarioRec[MAXSC
 };
 
 static str fillScenario(Client c, Scenario scen);
+static MT_Lock scenarioLock MT_LOCK_INITIALIZER("scenarioLock");
 
 /*
  * @-
@@ -156,7 +157,7 @@ getFreeScenario(void)
        int i;
        Scenario scen = NULL;
 
-       MT_lock_set(&mal_contextLock, "Scenario");
+       MT_lock_set(&scenarioLock, "Scenario");
        for (i = 0; i < MAXSCEN && scenarioRec[i].name; i++)
                ;
 
@@ -165,7 +166,7 @@ getFreeScenario(void)
        } else {
                scen = scenarioRec + i;
        }
-       MT_lock_unset(&mal_contextLock, "Scenario");
+       MT_lock_unset(&scenarioLock, "Scenario");
 
        return scen;
 }
@@ -228,6 +229,10 @@ initScenario(Client c, Scenario s)
 str
 defaultScenario(Client c)
 {
+#ifdef NEED_MT_LOCK_INIT
+       if (c == mal_clients)
+               MT_lock_init(&admissionLock, "admissionLock");
+#endif
        return initScenario(c, scenarioRec);
 }
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to