Changeset: 94552a691887 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/94552a691887
Modified Files:
monetdb5/mal/mal_dataflow.c
monetdb5/mal/mal_resource.c
monetdb5/mal/mal_resource.h
Branch: default
Log Message:
Small internal interface change.
diffs (115 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
@@ -370,19 +370,17 @@ DFLOWworker(void *T)
p= getInstrPtr(flow->mb,fe->pc);
claim = fe->argclaim;
- if (MALadmission_claim(flow->cntxt, flow->mb,
flow->stk, p, claim)) {
- // never block on deblockdataflow()
- if( p->fcn != (MALfcn) deblockdataflow){
- fe->hotclaim = 0; /* don't assume
priority anymore */
- fe->maxclaim = 0;
- MT_lock_set(&todo->l);
- int last = todo->last;
- MT_lock_unset(&todo->l);
- if (last == 0)
- MT_sleep_ms(DELAYUNIT);
- q_requeue(todo, fe);
- continue;
- }
+ if (p->fcn != (MALfcn) deblockdataflow && /* never
block on deblockdataflow() */
+ !MALadmission_claim(flow->cntxt, flow->mb,
flow->stk, p, claim)) {
+ fe->hotclaim = 0; /* don't assume priority
anymore */
+ fe->maxclaim = 0;
+ MT_lock_set(&todo->l);
+ int last = todo->last;
+ MT_lock_unset(&todo->l);
+ if (last == 0)
+ MT_sleep_ms(DELAYUNIT);
+ q_requeue(todo, fe);
+ continue;
}
ATOMIC_BASE_TYPE wrks =
ATOMIC_INC(&flow->cntxt->workers);
ATOMIC_BASE_TYPE mwrks = ATOMIC_GET(&flow->mb->workers);
@@ -440,14 +438,10 @@ DFLOWworker(void *T)
for (last = fe->pc - flow->start; last >= 0 && (i =
flow->nodes[last]) > 0; last = flow->edges[last]){
if (flow->status[i].state == DFLOWpending &&
flow->status[i].blocks == 1) {
/* find the one with the largest
footprint */
- if( nxt == -1){
+ if (nxt == -1 ||
flow->status[i].argclaim > nxtclaim) {
nxt = i;
nxtclaim =
flow->status[i].argclaim;
}
- if( flow->status[i].argclaim >
nxtclaim){
- nxt = i;
- nxtclaim =
flow->status[i].argclaim;
- }
}
}
/* hot potato can not be removed, use alternative to
proceed */
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
@@ -112,10 +112,9 @@ getMemoryClaim(MalBlkPtr mb, MalStkPtr s
*/
static MT_Lock admissionLock = MT_LOCK_INITIALIZER(admissionLock);
-int
+bool
MALadmission_claim(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci,
lng argclaim)
{
- (void) mb;
(void) pci;
/* Check if we are allowed to allocate another worker thread for this
client */
@@ -123,11 +122,11 @@ MALadmission_claim(Client cntxt, MalBlkP
* A way out is to attach the thread count to the MAL stacks, which
just limits the level
* of parallism for a single dataflow graph.
*/
- if (cntxt->workerlimit > 0 && (int) ATOMIC_GET(&cntxt->workers) >=
cntxt->workerlimit) {
- return -1;
- }
+ if (cntxt->workerlimit > 0 && (int) ATOMIC_GET(&cntxt->workers) >=
cntxt->workerlimit)
+ return false;
+
if (argclaim == 0)
- return 0;
+ return true;
MT_lock_set(&admissionLock);
/* Determine if the total memory resource is exhausted, because it is
overall limitation. */
@@ -143,7 +142,7 @@ MALadmission_claim(Client cntxt, MalBlkP
if ( cntxt->memorylimit) {
if (argclaim + stk->memory > (lng) cntxt->memorylimit *
LL_CONSTANT(1048576) && ATOMIC_GET(&cntxt->workers) > 0){
MT_lock_unset(&admissionLock);
- return -1;
+ return false;
}
stk->memory += argclaim;
}
@@ -154,10 +153,10 @@ MALadmission_claim(Client cntxt, MalBlkP
mb->memory = stk->memory;
MT_lock_unset(&mal_delayLock);
MT_lock_unset(&admissionLock);
- return 0;
+ return true;
}
MT_lock_unset(&admissionLock);
- return -1;
+ return false;
}
void
diff --git a/monetdb5/mal/mal_resource.h b/monetdb5/mal/mal_resource.h
--- a/monetdb5/mal/mal_resource.h
+++ b/monetdb5/mal/mal_resource.h
@@ -24,7 +24,7 @@
#define DELAYUNIT 2 /* ms delay in parallel processing decisions */
#define MAX_DELAYS 1000 /* never wait more then 2000 ms */
-extern int MALadmission_claim(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci, lng argclaim);
+extern bool MALadmission_claim(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci, lng argclaim);
extern void MALadmission_release(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci, lng argclaim);
#define FAIRNESS_THRESHOLD (MAX_DELAYS * DELAYUNIT)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]