Changeset: ed74b4c3b53c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ed74b4c3b53c
Modified Files:
gdk/gdk_batop.c
gdk/gdk_hash.c
gdk/gdk_orderidx.c
gdk/gdk_strimps.c
monetdb5/mal/mal.h
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_stack.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/rel_physical.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_gencode.h
sql/backends/monet5/sql_statement.c
sql/common/sql_types.c
sql/common/sql_types.h
sql/server/rel_basetable.c
sql/server/rel_basetable.h
sql/server/rel_distribute.c
sql/server/rel_dump.c
sql/server/rel_exp.c
sql/server/rel_exp.h
sql/server/rel_optimize_exps.c
sql/server/rel_optimize_others.c
sql/server/rel_optimize_proj.c
sql/server/rel_propagate.c
sql/server/rel_psm.c
sql/server/rel_rel.c
sql/server/rel_schema.c
sql/server/rel_select.c
sql/server/rel_sequence.c
sql/server/rel_statistics.c
sql/server/rel_statistics_functions.c
sql/server/rel_unnest.c
sql/server/rel_updates.c
sql/server/sql_atom.c
sql/server/sql_atom.h
sql/server/sql_env.c
sql/server/sql_parser.y
sql/server/sql_semantic.c
sql/storage/store.c
sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test
Branch: default
Log Message:
small changes to improve performance, do less work when possible (mostly in the
prepare/exec calls)
diffs (truncated from 2299 to 300 lines):
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -2985,9 +2985,11 @@ PROPdestroy_nolock(BAT *b)
void
PROPdestroy(BAT *b)
{
- MT_lock_set(&b->theaplock);
- PROPdestroy_nolock(b);
- MT_lock_unset(&b->theaplock);
+ if (b->tprops) {
+ MT_lock_set(&b->theaplock);
+ PROPdestroy_nolock(b);
+ MT_lock_unset(&b->theaplock);
+ }
}
ValPtr
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -1350,7 +1350,7 @@ HASHlist(Hash *h, BUN i)
void
HASHdestroy(BAT *b)
{
- if (b) {
+ if (b && b->thash) {
Hash *hs;
MT_rwlock_wrlock(&b->thashlock);
hs = b->thash;
diff --git a/gdk/gdk_orderidx.c b/gdk/gdk_orderidx.c
--- a/gdk/gdk_orderidx.c
+++ b/gdk/gdk_orderidx.c
@@ -534,7 +534,7 @@ OIDXfree(BAT *b)
void
OIDXdestroy(BAT *b)
{
- if (b) {
+ if (b && b->torderidx) {
Heap *hp;
MT_lock_set(&b->batIdxLock);
diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -1012,7 +1012,7 @@ STRMPincref(Strimps *strimps)
void
STRMPdestroy(BAT *b)
{
- if (b) {
+ if (b && b->tstrimps) {
MT_lock_set(&b->batIdxLock);
if (b->tstrimps == (Strimps *)1) {
b->tstrimps = NULL;
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -216,7 +216,6 @@ typedef struct MALSTK {
* It is handy to administer the timing in the stack frame
* for use in profiling instructions.
*/
- struct timeval clock; /* time this stack was created */
char status; /* running 'R' suspended 'S',
quitting 'Q' */
int pcup; /* saved pc upon a
recursive all */
oid tag; /* unique invocation
call tag */
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
@@ -512,7 +512,7 @@ runMALsequence(Client cntxt, MalBlkPtr m
if (startpc + 1 == stoppc) {
pci = getInstrPtr(mb, startpc);
if (pci->argc > 16) {
- backup = GDKmalloc(pci->argc * sizeof(ValRecord));
+ backup = GDKmalloc(pci->retc * sizeof(ValRecord));
garbage = (int *) GDKzalloc(pci->argc * sizeof(int));
if (backup == NULL || garbage == NULL) {
GDKfree(backup);
diff --git a/monetdb5/mal/mal_stack.c b/monetdb5/mal/mal_stack.c
--- a/monetdb5/mal/mal_stack.c
+++ b/monetdb5/mal/mal_stack.c
@@ -56,10 +56,24 @@ newGlobalStack(int size)
{
MalStkPtr s;
- s = (MalStkPtr) GDKzalloc(stackSize(size));
+ s = (MalStkPtr) GDKmalloc(stackSize(size));
if (!s)
return NULL;
s->stksize = size;
+ s->stktop = s->stkbot = s->stkdepth = s->calldepth = 0;
+ s->keepAlive = s->keepTmps = 0;
+ s->admit = s->wrapup = NULL;
+
+ s->status = 0;
+ s->pcup = 0;
+ s->tag = 0;
+ s->memory = 0;
+ s->up = NULL;
+ s->blk = NULL;
+ for(int i = 0; i < size; i++) {
+ s->stk[i].vtype = 0;
+ s->stk[i].bat = false;
+ }
return s;
}
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -484,7 +484,7 @@ handle_in_tuple_exps(backend *be, sql_ex
lstmts = append(lstmts, c);
}
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
sql_subfunc *and = sql_bind_func(sql, "sys", "and", bt, bt, F_FUNC,
true, true);
sql_subfunc *or = sql_bind_func(sql, "sys", "or", bt, bt, F_FUNC, true,
true);
for (node *n = nl->h; n; n = n->next) {
@@ -537,7 +537,7 @@ handle_in_exps(backend *be, sql_exp *ce,
c = stmt_const(be, bin_find_smallest_column(be, left), c);
if (c->nrcols == 0 || depth || !reduce) {
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
sql_subfunc *cmp = (in)
?sql_bind_func(sql, "sys", "=", tail_type(c),
tail_type(c), F_FUNC, true, true)
:sql_bind_func(sql, "sys", "<>", tail_type(c),
tail_type(c), F_FUNC, true, true);
@@ -693,7 +693,7 @@ exp_count_no_nil_arg(sql_exp *e, stmt *e
static stmt *
exp_bin_conjunctive(backend *be, sql_exp *e, stmt *left, stmt *right, stmt
*grp, stmt *ext, stmt *cnt, stmt *sel, int depth, bool reduce, int push)
{
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
list *l = e->l;
node *n;
stmt *sel1 = NULL, *s = NULL;
@@ -753,7 +753,7 @@ exp_bin_conjunctive(backend *be, sql_exp
static stmt *
exp_bin_disjunctive(backend *be, sql_exp *e, stmt *left, stmt *right, stmt
*grp, stmt *ext, stmt *cnt, stmt *sel, int depth, bool reduce, int push)
{
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
list *l = e->l;
node *n;
stmt *s = NULL, *cur = NULL;
@@ -800,7 +800,7 @@ exp2bin_case(backend *be, sql_exp *fe, s
stmt *res = NULL, *ires = NULL, *rsel = NULL, *osel = NULL, *ncond =
NULL, *ocond = NULL, *cond = NULL;
int next_cond = 1, single_value = (fe->card <= CARD_ATOM && (!left ||
!left->nrcols));
char name[16], *nme = NULL;
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL,
F_FUNC, true, true);
sql_subfunc *or = sql_bind_func(be->mvc, "sys", "or", bt, bt, F_FUNC,
true, true);
sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC,
true, true);
@@ -969,7 +969,7 @@ exp2bin_casewhen(backend *be, sql_exp *f
stmt *res = NULL, *ires = NULL, *rsel = NULL, *osel = NULL, *ncond =
NULL, *ocond = NULL, *cond = NULL;
int next_cond = 1, single_value = (fe->card <= CARD_ATOM && (!left ||
!left->nrcols));
char name[16], *nme = NULL;
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL,
F_FUNC, true, true);
sql_subfunc *or = sql_bind_func(be->mvc, "sys", "or", bt, bt, F_FUNC,
true, true);
sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC,
true, true);
@@ -1152,7 +1152,7 @@ exp2bin_coalesce(backend *be, sql_exp *f
stmt *res = NULL, *rsel = NULL, *osel = NULL, *ncond = NULL, *ocond =
NULL;
int single_value = (fe->card <= CARD_ATOM && (!left || !left->nrcols));
char name[16], *nme = NULL;
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC,
true, true);
sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL,
F_FUNC, true, true);
@@ -2737,8 +2737,8 @@ rel2bin_hash_lookup(backend *be, sql_rel
{
mvc *sql = be->mvc;
node *n;
- sql_subtype *it = sql_bind_localtype("int");
- sql_subtype *lng = sql_bind_localtype("lng");
+ sql_subtype *it = sql_fetch_localtype(TYPE_int);
+ sql_subtype *lng = sql_fetch_localtype(TYPE_lng);
stmt *h = NULL;
stmt *bits = stmt_atom_int(be, 1 +
((sizeof(lng)*8)-1)/(list_length(i->columns)+1));
sql_exp *e = en->data;
@@ -2814,8 +2814,8 @@ join_hash_key(backend *be, list *l)
stmt *h = NULL;
stmt *bits = stmt_atom_int(be, 1 +
((sizeof(lng)*8)-1)/(list_length(l)+1));
- it = sql_bind_localtype("int");
- lng = sql_bind_localtype("lng");
+ it = sql_fetch_localtype(TYPE_int);
+ lng = sql_fetch_localtype(TYPE_lng);
for (m = l->h; m; m = m->next) {
stmt *s = m->data;
@@ -3208,7 +3208,7 @@ rel2bin_groupjoin(backend *be, sql_rel *
if (exp_is_atom(e) && need_no_nil(e))
m = sql_Nop_(be, "ifthenelse",
sql_unop_(be, "isnull", m), stmt_bool(be, false), m, NULL);
if (!exist) {
- sql_subtype *bt =
sql_bind_localtype("bit");
+ sql_subtype *bt =
sql_fetch_localtype(TYPE_bit);
sql_subfunc *not =
sql_bind_func(be->mvc, "sys", "not", bt, NULL, F_FUNC, true, true);
m = stmt_unop(be, m, NULL, not);
}
@@ -3494,7 +3494,7 @@ rel2bin_join(backend *be, sql_rel *rel,
stmt *s = stmt_unop(be, last, NULL, isnil);
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt,
NULL, F_FUNC, true, true);
s = stmt_unop(be, s, NULL, not);
@@ -3620,7 +3620,7 @@ rel2bin_antijoin(backend *be, sql_rel *r
stmt *s = exp_bin(be, en->data, sub, NULL, NULL, NULL,
NULL, NULL /* sel */, 0, 0/* just the project call not the select*/, 0);
/* ifthenelse if (not(predicate)) then false else true
(needed for antijoin) */
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not",
bt, NULL, F_FUNC, true, true);
s = stmt_unop(be, s, NULL, not);
s = sql_Nop_(be, "ifthenelse", s, stmt_bool(be, 0),
stmt_bool(be, 1), NULL);
@@ -4101,7 +4101,7 @@ stmt_limit_value(backend *be, sql_rel *t
if(!l)
return NULL;
if (oe) {
- sql_subtype *lng = sql_bind_localtype("lng");
+ sql_subtype *lng =
sql_fetch_localtype(TYPE_lng);
sql_subfunc *add =
sql_bind_func_result(be->mvc, "sys", "sql_add", F_FUNC, true, lng, 2, lng, lng);
stmt *o = exp_bin(be, oe, NULL, NULL, NULL,
NULL, NULL, NULL, 0, 0, 0);
if(!o)
@@ -4147,7 +4147,7 @@ rel2bin_recursive_munion(backend *be, sq
refs_update_stmt(refs, base, rel_stmt);
/* cnt = count(temptable) */
- sql_subfunc *cnt = sql_bind_func(sql, "sys", "count",
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
+ sql_subfunc *cnt = sql_bind_func(sql, "sys", "count",
sql_fetch_localtype(TYPE_void), NULL, F_AGGR, true, true);
stmt *cnts = stmt_aggr(be, rel_stmt->op4.lval->h->data, NULL,
NULL, cnt, 1, 0, 1);
/* if topn keep total count */
@@ -4341,7 +4341,7 @@ static stmt *
rel2bin_except(backend *be, sql_rel *rel, list *refs)
{
mvc *sql = be->mvc;
- sql_subtype *lng = sql_bind_localtype("lng");
+ sql_subtype *lng = sql_fetch_localtype(TYPE_lng);
list *stmts;
node *n, *m;
stmt *left = NULL, *right = NULL, *sub;
@@ -4455,7 +4455,7 @@ static stmt *
rel2bin_inter(backend *be, sql_rel *rel, list *refs)
{
mvc *sql = be->mvc;
- sql_subtype *lng = sql_bind_localtype("lng");
+ sql_subtype *lng = sql_fetch_localtype(TYPE_lng);
list *stmts;
node *n, *m;
stmt *left = NULL, *right = NULL, *sub;
@@ -4865,7 +4865,7 @@ rel2bin_select(backend *be, sql_rel *rel
else if (!predicate)
predicate = const_column(be, stmt_bool(be, 1));
if (e->type != e_cmp) {
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
s = stmt_convert(be, s, NULL, exp_subtype(e),
bt);
}
@@ -5170,9 +5170,9 @@ insert_check_ukey(backend *be, list *ins
char *msg = NULL;
stmt *res;
- sql_subtype *lng = sql_bind_localtype("lng");
- sql_subfunc *cnt = sql_bind_func(sql, "sys", "count",
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *lng = sql_fetch_localtype(TYPE_lng);
+ sql_subfunc *cnt = sql_bind_func(sql, "sys", "count",
sql_fetch_localtype(TYPE_void), NULL, F_AGGR, true, true);
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
stmt *dels = stmt_tid(be, k->t, 0);
sql_subfunc *ne = sql_bind_func_result(sql, "sys", "<>", F_FUNC, true,
bt, 2, lng, lng);
@@ -5342,9 +5342,9 @@ insert_check_fkey(backend *be, list *ins
mvc *sql = be->mvc;
char *msg = NULL;
stmt *cs = list_fetch(inserts, 0), *s = cs;
- sql_subtype *lng = sql_bind_localtype("lng");
- sql_subfunc *cnt = sql_bind_func(sql, "sys", "count",
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
- sql_subtype *bt = sql_bind_localtype("bit");
+ sql_subtype *lng = sql_fetch_localtype(TYPE_lng);
+ sql_subfunc *cnt = sql_bind_func(sql, "sys", "count",
sql_fetch_localtype(TYPE_void), NULL, F_AGGR, true, true);
+ sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
sql_subfunc *ne = sql_bind_func_result(sql, "sys", "<>", F_FUNC, true,
bt, 2, lng, lng);
stmt *nonil_rows = NULL;
@@ -5491,7 +5491,7 @@ sql_insert_check(backend *be, sql_key *k
}
stmt *sub = stmt_list(be, ins);
stmt *s = exp_bin(be, exp, sub, NULL, NULL, NULL, NULL, NULL, 0, 0, 0);
- sql_subfunc *cnt = sql_bind_func(sql, "sys", "count",
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
+ sql_subfunc *cnt = sql_bind_func(sql, "sys", "count",
sql_fetch_localtype(TYPE_void), NULL, F_AGGR, true, true);
s = stmt_uselect(be, column(be, s), stmt_bool(be, 0), cmp_equal, NULL,
0, 1);
s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]