Changeset: b88a936ebaa4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b88a936ebaa4
Modified Files:
monetdb5/mal/mal_dataflow.c
monetdb5/mal/mal_interpreter.c
Branch: resource_management
Log Message:
fix allocator placement in tls in dataflow
diffs (109 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
@@ -253,7 +253,8 @@ DFLOWworker(void *T)
#endif
GDKsetbuf(t->errbuf); /* where to leave errors */
snprintf(t->s.name, sizeof(t->s.name), "DFLOWsema%04zu", MT_getpid());
- allocator *ta = create_allocator(NULL, "TA_tls", false);
+ allocator *ma = create_allocator(NULL, "TA_tls", false);
+ MT_thread_setallocator(ma);
for (;;) {
DataFlow flow;
@@ -337,12 +338,11 @@ DFLOWworker(void *T)
break;
}
- allocator *ma = flow->mb->ma;
- MT_thread_setallocator(ma);
- error = runMALsequence(ta, flow->cntxt, flow->mb,
fe->pc, fe->pc + 1,
+ error = runMALsequence(ma, flow->cntxt, flow->mb,
fe->pc, fe->pc + 1,
flow->stk,
0, 0);
- MT_thread_setallocator(NULL);
- sa_reset(ta);
+ if (error)
+ error = MA_STRDUP(flow->mb->ma, error);
+ sa_reset(ma);
ATOMIC_DEC(&flow->cntxt->workers);
/* release the memory claim */
@@ -452,7 +452,7 @@ DFLOWworker(void *T)
}
MT_lock_unset(&dataflowLock);
GDKsetbuf(NULL);
- ma_destroy(ta);
+ ma_destroy(ma);
}
/*
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -489,7 +489,7 @@ callMAL(Client cntxt, MalBlkPtr mb, MalS
* instruction, we take the wall-clock time for resource management.
*/
str
-runMALsequence(allocator *tmp_alloc, Client cntxt, MalBlkPtr mb, int startpc,
+runMALsequence(allocator *ma, Client cntxt, MalBlkPtr mb, int startpc,
int stoppc, MalStkPtr stk, MalStkPtr env, InstrPtr
pcicaller)
{
ValPtr lhs, rhs, v;
@@ -513,8 +513,8 @@ runMALsequence(allocator *tmp_alloc, Cli
if (startpc + 1 == stoppc) {
pci = getInstrPtr(mb, startpc);
if (pci->argc > 16) {
- backup = ma_alloc(tmp_alloc, pci->retc *
sizeof(ValRecord));
- garbage = (int *) ma_zalloc(tmp_alloc, pci->argc *
sizeof(int));
+ backup = ma_alloc(ma, pci->retc * sizeof(ValRecord));
+ garbage = (int *) ma_zalloc(ma, pci->argc *
sizeof(int));
if (backup == NULL || garbage == NULL) {
//GDKfree(backup);
//GDKfree(garbage);
@@ -526,8 +526,8 @@ runMALsequence(allocator *tmp_alloc, Cli
memset(garbages, 0, sizeof(garbages));
}
} else if (mb->maxarg > 16) {
- backup = ma_alloc(tmp_alloc, mb->maxarg * sizeof(ValRecord));
- garbage = (int *) ma_zalloc(tmp_alloc, mb->maxarg *
sizeof(int));
+ backup = ma_alloc(ma, mb->maxarg * sizeof(ValRecord));
+ garbage = (int *) ma_zalloc(ma, mb->maxarg * sizeof(int));
if (backup == NULL || garbage == NULL) {
//GDKfree(backup);
//GDKfree(garbage);
@@ -770,7 +770,7 @@ runMALsequence(allocator *tmp_alloc, Cli
InstrPtr q;
int ii, arg;
- nstk = prepareMALstack(tmp_alloc, pci->blk,
pci->blk->vsize);
+ nstk = prepareMALstack(ma, pci->blk, pci->blk->vsize);
if (nstk == 0) {
ret = createException(MAL, "mal.interpreter",
MAL_STACK_FAIL);
break;
@@ -801,7 +801,7 @@ runMALsequence(allocator *tmp_alloc, Cli
for (ii = pci->retc; ii < pci->argc; ii++, arg++) {
lhs = &nstk->stk[q->argv[arg]];
rhs = &stk->stk[pci->argv[ii]];
- if (VALcopy(tmp_alloc, lhs, rhs) == NULL) {
+ if (VALcopy(ma, lhs, rhs) == NULL) {
//GDKfree(nstk);
ret = createException(MAL,
"mal.interpreter",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -810,7 +810,7 @@ runMALsequence(allocator *tmp_alloc, Cli
BBPretain(lhs->val.bval);
}
if (ret == MAL_SUCCEED && ii == pci->argc) {
- ret = runMALsequence(tmp_alloc, cntxt,
pci->blk, 1, pci->blk->stop, nstk,
+ ret = runMALsequence(ma, cntxt, pci->blk, 1,
pci->blk->stop, nstk,
stk,
pci);
garbageCollector(cntxt, pci->blk, nstk, 0);
arg = q->retc;
@@ -1216,7 +1216,7 @@ runMALsequence(allocator *tmp_alloc, Cli
for (int i = 0; i < pci->retc; i++) {
rhs = &stk->stk[pp->argv[i]];
lhs = &env->stk[pci->argv[i]];
- if (VALcopy(tmp_alloc, lhs, rhs) ==
NULL) {
+ if (VALcopy(ma, lhs, rhs) == NULL) {
ret = createException(MAL,
"mal.interpreter",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
break;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]