Changeset: d9ce6ac92b92 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d9ce6ac92b92
Modified Files:
monetdb5/mal/mal_interpreter.mx
Branch: Mar2011
Log Message:
Reduce cost of eligibility check
In addition to the low-end test for dataflow eligible instructions,
we now also keep a 'lookahead' limit, which marks the last instruction
where eligibility may occur due to variable use.
Only when no candidate is found we look for all.
This, hopefully, trims down the cost of searching eligible instructions
in the case threads have to wait for freeing up variables.
diffs (74 lines):
diff --git a/monetdb5/mal/mal_interpreter.mx b/monetdb5/mal/mal_interpreter.mx
--- a/monetdb5/mal/mal_interpreter.mx
+++ b/monetdb5/mal/mal_interpreter.mx
@@ -1337,11 +1337,11 @@
{
int queued = 0, candidates;
int todo = 0, done = 0;
- int pc = 0, i, j, oa =0, ia;
- int limit = flow->stop - flow->start;
+ int pc = 0, i, j, oa =0, ia,k;
+ int limit = flow->stop - flow->start, lookahead =0;
str ret = MAL_SUCCEED;
FlowStep fs = (FlowStep)alloca(sizeof(FlowStepRec) * limit), f = 0;
- InstrPtr p;
+ InstrPtr p, last=0;
if ( limit == 0)
throw(MAL,"dataflow","Empty dataflow block");
@@ -1401,31 +1401,43 @@
/* deblock the output args */
for(j=0; j<p->retc; j++) {
oa = getArg(p,j);
+ /* find the last instruction that should be
inspected for eligibility */
+ if ( getEndOfLife(flow->mb,oa) > lookahead)
+ lookahead = getEndOfLife(flow->mb,oa);
flow->blocked[oa] = 0;
flow->inuse[oa] = 0;
}
+ last = p;
}
firststep:
PARDEBUG if (queued)
mnstr_printf(GDKstdout,"#schedule new instructions,
start from %d\n", pc);
+ /* avoid the head of the flow that has already been handled */
for( ; pc < limit; pc++)
if ( fs[pc].status != DFLOWwrapup)
break;
+ if (lookahead <= pc)
+ lookahead = pc+1;
+ if ( lookahead > limit)
+ lookahead = limit;
+
if (flow->stk->admit == 0) {
@:DFLOWscheduler_body( DFLOWeligible(flow,fs,i,p,pc) )@
} else {
@:DFLOWscheduler_body( DFLOWeligible(flow,fs,i,p,pc) &&
(*flow->stk->admit)(flow->cntxt, flow->mb, flow->stk, p) )@
}
@= DFLOWscheduler_body
- /* first try to find all instructions that use the released
target */
+ /* first try to find all instructions that use any of the
released targets */
candidates = 0;
- for(i = pc; i < limit ; i++)
+ if ( last)
+ for(i = pc; i < lookahead ; i++)
if (fs[i].status == DFLOWpending ) {
p = getInstrPtr(flow->mb, fs[i].pc);
for ( j= p->retc; j < p->argc; j++)
- if ( getArg(p,j)== oa ) {
+ for ( k= 0; k < last->retc; k++)
+ if ( getArg(p,j)== getArg(last,k) ) {
if ( @1 ) {
queued++;
todo++;
@@ -1453,7 +1465,7 @@
PARDEBUG {
int candidates = 0;
mnstr_printf(GDKstdout,"#end of data flow %d %d todo %d done
%d\n",pc,limit,todo,done);
- for ( i =0 ; i<limit; i++)
+ for ( i =0 ; i<lookahead; i++)
if (fs[i].status != DFLOWwrapup && fs[i].pc >=0) {
mnstr_printf(GDKstdout,"#missed %d %d %d ", i,
fs[i].status, fs[i].pc);
printInstruction(GDKstdout, flow->mb, 0,
getInstrPtr(flow->mb,fs[i].pc), LIST_MAL_STMT | LIST_MAPI);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list