Changeset: 976b124d0597 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/976b124d0597
Modified Files:
monetdb5/mal/mal.h
monetdb5/mal/mal_instruction.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/optimizer/opt_aliases.c
monetdb5/optimizer/opt_coercion.c
monetdb5/optimizer/opt_commonTerms.c
monetdb5/optimizer/opt_constants.c
monetdb5/optimizer/opt_dataflow.c
monetdb5/optimizer/opt_deadcode.c
monetdb5/optimizer/opt_dict.c
monetdb5/optimizer/opt_emptybind.c
monetdb5/optimizer/opt_evaluate.c
monetdb5/optimizer/opt_for.c
monetdb5/optimizer/opt_generator.c
monetdb5/optimizer/opt_inline.c
monetdb5/optimizer/opt_mergetable.c
monetdb5/optimizer/opt_multiplex.c
monetdb5/optimizer/opt_projectionpath.c
monetdb5/optimizer/opt_pushselect.c
monetdb5/optimizer/opt_remap.c
monetdb5/optimizer/opt_remoteQueries.c
monetdb5/optimizer/opt_reorder.c
Branch: Dec2025
Log Message:
Remove MalBlk temporary allocator, use thread-local allocator instead.
diffs (truncated from 1116 to 300 lines):
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -181,7 +181,6 @@ typedef struct MALBLK {
str errors; /* left over errors */
int maxarg; /* keep track on the
maximal arguments used */
allocator *ma; /* mal blocks are fully
allocated using a single allocator */
- allocator *ta; /* temporary allocator */
allocator *instr_allocator; /* mal instructions allocator */
/* During the run we keep track on the maximum number of concurrent
threads and memory claim */
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -122,11 +122,6 @@ newMalBlk(int elements)
if (!ma)
return NULL;
- allocator *ta = create_allocator(ma, "TA_MALBlk", true);
- if (ta == NULL) {
- ma_destroy(ma);
- return NULL;
- }
allocator *instr_allocator = create_allocator(ma, "MA_MALInstructions",
false);
if (instr_allocator == NULL) {
ma_destroy(ma);
@@ -156,7 +151,6 @@ newMalBlk(int elements)
.maxarg = MAXARG, /* the minimum for each
instruction */
.workers = ATOMIC_VAR_INIT(1),
.ma = ma,
- .ta = ta,
.instr_allocator = instr_allocator
};
if (newMalBlkStmt(mb, elements) < 0) {
@@ -340,7 +334,6 @@ copyMalBlk(MalBlkPtr old)
}
mb->ma = ma;
- mb->ta = create_allocator(ma, ma_name(old->ta), true);
mb->instr_allocator = create_allocator(ma,
ma_name(old->instr_allocator), true);
mb->var = MA_ZNEW_ARRAY(ma, VarRecord, old->vsize);
if (mb->var == NULL) {
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -1350,7 +1350,7 @@ SERVERclient(Client ctx, void *res, cons
char *f;
\
allocator *ta = MT_thread_getallocator();
\
allocator_state ta_state = ma_open(ta);
\
-
\
+
\
if (hdl && mapi_result_error(hdl))
\
err = mapi_result_error(hdl);
\
else
\
@@ -1366,9 +1366,9 @@ SERVERclient(Client ctx, void *res, cons
}
\
\
f = newerr;
\
- /* I think this code tries to deal with multiple
errors, this \
- * will fail this way if it does, since no ! is in the
error \
- * string, only newlines to separate them */
\
+ /* I think this code tries to deal with multiple
errors, */ \
+ /* this will fail this way if it does, since no ! is in
the */ \
+ /* error string, only newlines to separate them */
\
for (e = err; *e && l > 1; e++) {
\
if (*e == '!' && *(e - 1) == '\n') {
\
snprintf(f, l, "MALException:" fcn
":remote error:"); \
@@ -2186,9 +2186,9 @@ SERVERmapi_rpc_single_row(Client ctx, Ma
int key, i, j;
Mapi mid;
MapiHdl hdl;
- char *s, *fld, *qry = 0;
+ char *s, *fld, *qry = NULL;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
allocator_state ta_state = ma_open(ta);
key = *getArgReference_int(stk, pci, pci->retc);
accessTest(key, "rpc");
@@ -2198,23 +2198,24 @@ SERVERmapi_rpc_single_row(Client ctx, Ma
/* glue all strings together */
for (i = pci->retc + 1; i < pci->argc; i++) {
fld = *getArgReference_str(stk, pci, i);
- if (qry == 0) {
+ if (qry == NULL) {
qry = ma_strdup(ta, fld);
- if (qry == NULL)
+ if (qry == NULL) {
+ ma_close(ta, &ta_state);
throw(MAL, "mapi.rpc", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ }
} else {
s = (char *) ma_alloc(ta, strlen(qry) + strlen(fld) +
1);
if (s == NULL) {
- //GDKfree(qry);
+ ma_close(ta, &ta_state);
throw(MAL, "mapi.rpc", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
}
stpcpy(stpcpy(s, qry), fld);
- //GDKfree(qry);
qry = s;
}
}
hdl = mapi_query(mid, qry);
- //GDKfree(qry);
+ ma_close(ta, &ta_state);
catchErrors("mapi.rpc");
i = 0;
@@ -2253,7 +2254,6 @@ SERVERmapi_rpc_single_row(Client ctx, Ma
i++;
}
mapi_close_handle(hdl);
- ma_close(ta, &ta_state);
if (i > 1)
throw(MAL, "mapi.rpc", "Too many answers");
return MAL_SUCCEED;
diff --git a/monetdb5/optimizer/opt_aliases.c b/monetdb5/optimizer/opt_aliases.c
--- a/monetdb5/optimizer/opt_aliases.c
+++ b/monetdb5/optimizer/opt_aliases.c
@@ -24,7 +24,7 @@ OPTaliasesImplementation(Client ctx, Mal
int *alias = 0;
str msg = MAL_SUCCEED;
InstrPtr p;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
(void) stk;
(void) ctx;
diff --git a/monetdb5/optimizer/opt_coercion.c
b/monetdb5/optimizer/opt_coercion.c
--- a/monetdb5/optimizer/opt_coercion.c
+++ b/monetdb5/optimizer/opt_coercion.c
@@ -99,7 +99,7 @@ OPTcoercionImplementation(Client ctx, Ma
InstrPtr p;
int actions = 0;
str msg = MAL_SUCCEED;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
if (MB_LARGE(mb))
goto wrapup;
diff --git a/monetdb5/optimizer/opt_commonTerms.c
b/monetdb5/optimizer/opt_commonTerms.c
--- a/monetdb5/optimizer/opt_commonTerms.c
+++ b/monetdb5/optimizer/opt_commonTerms.c
@@ -61,7 +61,7 @@ OPTcommonTermsImplementation(Client ctx,
str msg = MAL_SUCCEED;
InstrPtr *old = NULL;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
/* catch simple insert operations */
if (isSimpleSQL(mb) || MB_LARGE(mb)) {
diff --git a/monetdb5/optimizer/opt_constants.c
b/monetdb5/optimizer/opt_constants.c
--- a/monetdb5/optimizer/opt_constants.c
+++ b/monetdb5/optimizer/opt_constants.c
@@ -41,7 +41,7 @@ OPTconstantsImplementation(Client ctx, M
VarPtr x, y, *cst = NULL;
str msg = MAL_SUCCEED;
InstrPtr p, q;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
if (isSimpleSQL(mb) || MB_LARGE(mb)) {
goto wrapup1;
diff --git a/monetdb5/optimizer/opt_dataflow.c
b/monetdb5/optimizer/opt_dataflow.c
--- a/monetdb5/optimizer/opt_dataflow.c
+++ b/monetdb5/optimizer/opt_dataflow.c
@@ -346,7 +346,7 @@ OPTdataflowImplementation(Client ctx, Ma
States states = NULL;
region_state state = { singleton_region };
str msg = MAL_SUCCEED;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
/* don't use dataflow on single processor systems */
if (GDKnr_threads <= 1 || ctx->workerlimit == 1 || MB_LARGE(mb))
diff --git a/monetdb5/optimizer/opt_deadcode.c
b/monetdb5/optimizer/opt_deadcode.c
--- a/monetdb5/optimizer/opt_deadcode.c
+++ b/monetdb5/optimizer/opt_deadcode.c
@@ -24,7 +24,7 @@ OPTdeadcodeImplementation(Client ctx, Ma
int actions = 0;
int *varused = 0;
str msg = MAL_SUCCEED;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
(void) ctx;
(void) stk;
diff --git a/monetdb5/optimizer/opt_dict.c b/monetdb5/optimizer/opt_dict.c
--- a/monetdb5/optimizer/opt_dict.c
+++ b/monetdb5/optimizer/opt_dict.c
@@ -41,7 +41,7 @@ OPTdictImplementation(Client ctx, MalBlk
int *varisdict = NULL, *vardictvalue = NULL;
bit *dictunique = NULL;
str msg = MAL_SUCCEED;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
(void) stk;
diff --git a/monetdb5/optimizer/opt_emptybind.c
b/monetdb5/optimizer/opt_emptybind.c
--- a/monetdb5/optimizer/opt_emptybind.c
+++ b/monetdb5/optimizer/opt_emptybind.c
@@ -49,7 +49,7 @@ OPTemptybindImplementation(Client ctx, M
str sch, tbl;
int etop = 0, esize = 256;
str msg = MAL_SUCCEED;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
(void) stk;
(void) ctx;
diff --git a/monetdb5/optimizer/opt_evaluate.c
b/monetdb5/optimizer/opt_evaluate.c
--- a/monetdb5/optimizer/opt_evaluate.c
+++ b/monetdb5/optimizer/opt_evaluate.c
@@ -132,7 +132,7 @@ OPTevaluateImplementation(Client ctx, Ma
int actions = 0, constantblock = 0;
int *assigned = 0, use;
str msg = MAL_SUCCEED;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
(void) stk;
diff --git a/monetdb5/optimizer/opt_for.c b/monetdb5/optimizer/opt_for.c
--- a/monetdb5/optimizer/opt_for.c
+++ b/monetdb5/optimizer/opt_for.c
@@ -42,7 +42,7 @@ OPTforImplementation(Client ctx, MalBlkP
int actions = 0;
int *varisfor = NULL, *varforvalue = NULL;
str msg = MAL_SUCCEED;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
(void) stk;
diff --git a/monetdb5/optimizer/opt_generator.c
b/monetdb5/optimizer/opt_generator.c
--- a/monetdb5/optimizer/opt_generator.c
+++ b/monetdb5/optimizer/opt_generator.c
@@ -103,7 +103,7 @@ OPTgeneratorImplementation(Client ctx, M
//const char *dblRef = getName("dbl");
str msg = MAL_SUCCEED;
int needed = 0;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
(void) stk;
diff --git a/monetdb5/optimizer/opt_inline.c b/monetdb5/optimizer/opt_inline.c
--- a/monetdb5/optimizer/opt_inline.c
+++ b/monetdb5/optimizer/opt_inline.c
@@ -21,7 +21,7 @@ inlineMALblock(Client ctx, MalBlkPtr mb,
int i, k, l, n;
InstrPtr *ns, p, q;
int *nv;
- allocator *ta = mb->ta;
+ allocator *ta = MT_thread_getallocator();
(void) ctx;
diff --git a/monetdb5/optimizer/opt_mergetable.c
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -298,22 +298,22 @@ overlap(allocator *ma, matlist_t *ml, in
}
static int
-mat_set_prop(matlist_t *ml, MalBlkPtr mb, InstrPtr p)
+mat_set_prop(allocator *ma, matlist_t *ml, MalBlkPtr mb, InstrPtr p)
{
int k, tpe = getArgType(mb, p, 0);
tpe = getBatType(tpe);
for (k = 1; k < p->argc; k++) {
- if (setPartnr(mb->ta, ml, -1, getArg(p, k), k))
+ if (setPartnr(ma, ml, -1, getArg(p, k), k))
return -1;
- if (tpe == TYPE_oid && propagateMirror(mb->ta, ml, getArg(p,
k), getArg(p, k)))
+ if (tpe == TYPE_oid && propagateMirror(ma, ml, getArg(p, k),
getArg(p, k)))
return -1;
}
return 0;
}
static InstrPtr
-mat_delta(matlist_t *ml, MalBlkPtr mb, InstrPtr p, mat_t *mat, int m, int n,
+mat_delta(allocator *ma, matlist_t *ml, MalBlkPtr mb, InstrPtr p, mat_t *mat,
int m, int n,
int o, int e, int mvar, int nvar, int ovar, int evar)
{
int tpe, k, j, is_subdelta = (getFunctionId(p) == subdeltaRef),
@@ -334,7 +334,7 @@ mat_delta(matlist_t *ml, MalBlkPtr mb, I
for (k = 1; k < mat[e].mi->argc; k++) {
for (j = 1; j < mat[m].mi->argc; j++) {
InstrPtr q;
- switch (overlap(mb->ta, ml, getArg(mat[e].mi,
k), getArg(mat[m].mi, j), k, j, 0)) {
+ switch (overlap(ma, ml, getArg(mat[e].mi, k),
getArg(mat[m].mi, j), k, j, 0)) {
case 0:
continue;
case -1:
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]