Changeset: 7eddf5fb638b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7eddf5fb638b
Modified Files:
        monetdb5/mal/mal_dataflow.c
Branch: default
Log Message:

Slight change in dataflow scheduling.
The multi-user experiments that especially in low number of
users it makes a noticable difference to give preference to
the oldest pending eligible instruction. It increases the
chance that the intermediate is still around in memory.
For large number of concurrent users the effect disappears.


diffs (67 lines):

diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c
--- a/monetdb5/mal/mal_dataflow.c
+++ b/monetdb5/mal/mal_dataflow.c
@@ -207,7 +207,8 @@ q_requeue(Queue *q, FlowEvent d)
 static FlowEvent
 q_dequeue(Queue *q, Client cntxt)
 {
-       FlowEvent r = NULL;
+       FlowEvent r = NULL, s = NULL;
+       int i;
 
        assert(q);
        MT_sema_down(&q->s, "q_dequeue");
@@ -215,19 +216,31 @@ q_dequeue(Queue *q, Client cntxt)
                return NULL;
        MT_lock_set(&q->l, "q_dequeue");
        if (cntxt) {
-               int i;
+               int i, minpc = -1;
 
                for (i = q->last - 1; i >= 0; i--) {
                        if (q->data[i]->flow->cntxt == cntxt) {
+                               if(minpc < 0){
+                                       minpc = i;
+                                       s = q->data[i];
+                               }
                                r = q->data[i];
-                               q->last--;
-                               while (i < q->last) {
-                                       q->data[i] = q->data[i + 1];
-                                       i++;
+                               if( s && r && s->pc > r->pc){
+                                       minpc = i;
+                                       s = r;
                                }
-                               break;
                        }
                }
+               if( minpc >= 0){
+                       r = q->data[minpc];
+                       i = minpc;
+                       q->last--;
+                       while (i < q->last) {
+                               q->data[i] = q->data[i + 1];
+                               i++;
+                       }
+               } else r = NULL;
+
                MT_lock_unset(&q->l, "q_dequeue");
                return r;
        }
@@ -240,6 +253,15 @@ q_dequeue(Queue *q, Client cntxt)
        if (q->last > 0) {
                /* LIFO favors garbage collection */
                r = q->data[--q->last];
+               for(i= q->last-1; r &&  i>=0; i--){
+                       s= q->data[i];
+                       if( s && s->flow && s->flow->stk &&
+                           r && r->flow && r->flow->stk &&
+                           s->flow->stk->tag < r->flow->stk->tag){
+                               q->data[i]= r;
+                               r = s;
+                       }
+               }
                q->data[q->last] = 0;
        }
        /* else: terminating */
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to