Changeset: 415137f10b8b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/415137f10b8b
Modified Files:
        monetdb5/mal/mal_pipelines.c
Branch: default
Log Message:

small improvement of the workers resource control


diffs (55 lines):

diff --git a/monetdb5/mal/mal_pipelines.c b/monetdb5/mal/mal_pipelines.c
--- a/monetdb5/mal/mal_pipelines.c
+++ b/monetdb5/mal/mal_pipelines.c
@@ -33,7 +33,6 @@ static struct worker {
        ATOMIC_PTR_TYPE cntxt;  /* client we do work for (NULL -> any) */
        Queue *q;                               /* pipeline tasks to execute */
        int self;
-       int used;
 } workers[THREADS];
 static int pipelines_initialized = 0;
 
@@ -231,7 +230,6 @@ PIPELINEworker(void *T)
                        freeStack(stk);
                        ma_close(&ma_state);
                        GDKfree(p->wls);
-                       t->used = 0;
                        MT_sema_up(&s->s);
                }
                GDKfree(p);
@@ -319,22 +317,25 @@ runMALpipelines(Client cntxt, MalBlkPtr 
        /* somehow get number of workers from statement/barrier */
        int j = s->nr_workers;
        while (j) {
-               for (int i = 0; i < GDKnr_threads && j > 0; i++) {
-                       if (!workers[i].used) {
-                               q_enqueue(workers[i].q, s);
+               for (int i = 0; i < GDKnr_threads && j > 0; i++)
+                       if (!workers[i].q->last)
                                j--;
+               if (j < s->nr_workers) {
+                       /* run with less threads ?? */
+                       s->nr_workers -= j;
+                       for (int i = 0, k = s->nr_workers; i < GDKnr_threads && 
k > 0; i++) {
+                               if (!workers[i].q->last) {
+                                       q_enqueue(workers[i].q, s);
+                                       k--;
+                               }
                        }
+                       j = 0;
                }
                if (j) {
-                       if (j < s->nr_workers) {
-                               /* run with less threads ?? */
-                               s->nr_workers -= j;
-                       } else {
-                               /* here we should wait */
+                       /* here we should wait */
        MT_lock_unset(&pipelineLock);
-                               MT_sleep_ms(1000);
+                       MT_sleep_ms(100);
        MT_lock_set(&pipelineLock);
-                       }
                }
        }
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to