Changeset: bdf37a61ba3a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bdf37a61ba3a
Modified Files:
MonetDB5/src/mal/mal_profiler.mx
MonetDB5/src/modules/mal/pcre.mx
MonetDB5/src/optimizer/opt_mergetable.mx
MonetDB5/src/optimizer/opt_prelude.mx
Branch: default
Log Message:
merged Niels' & Martin's latest fixes from Jun2010
diffs (truncated from 307 to 300 lines):
diff -r 218280d84a3e -r bdf37a61ba3a MonetDB5/src/mal/mal_profiler.mx
--- a/MonetDB5/src/mal/mal_profiler.mx Sun Aug 15 21:13:29 2010 +0200
+++ b/MonetDB5/src/mal/mal_profiler.mx Sun Aug 15 22:31:47 2010 +0200
@@ -1001,6 +1001,7 @@
t = BATnew(TYPE_str, TYPE_bat, 9);
if (t == NULL)
return NULL;
+ mal_set_lock(mal_profileLock, "profileLock");
BUNins(t, "event", &TRACE_id_event->batCacheid, FALSE);
BUNins(t, "clk", &TRACE_id_time->batCacheid, FALSE);
BUNins(t, "pc", &TRACE_id_pc->batCacheid, FALSE);
@@ -1013,6 +1014,7 @@
BUNins(t, "wbytes", &TRACE_id_wbytes->batCacheid, FALSE);
BUNins(t, "type", &TRACE_id_type->batCacheid, FALSE);
BUNins(t, "stmt", &TRACE_id_stmt->batCacheid, FALSE);
+ mal_unset_lock(mal_profileLock, "profileLock");
return t;
}
@@ -1044,11 +1046,29 @@
return b;
}
-int
-initTrace(void)
+
+#define CLEANUPprofile(X) if (X) { BBPdecref((X)->batCacheid, TRUE);
(X)->batPersistence = TRANSIENT; } (X) = NULL;
+
+void
+_cleanupProfiler(void)
{
- if (TRACE_init)
- return 0; /* already initialized */
+ CLEANUPprofile(TRACE_id_event);
+ CLEANUPprofile(TRACE_id_time);
+ CLEANUPprofile(TRACE_id_pc);
+ CLEANUPprofile(TRACE_id_stmt);
+ CLEANUPprofile(TRACE_id_type);
+ CLEANUPprofile(TRACE_id_rbytes);
+ CLEANUPprofile(TRACE_id_wbytes);
+ CLEANUPprofile(TRACE_id_reads);
+ CLEANUPprofile(TRACE_id_writes);
+ CLEANUPprofile(TRACE_id_thread);
+ CLEANUPprofile(TRACE_id_user);
+ TRACE_init = 0;
+}
+
+void
+_initTrace(void)
+{
TRACE_id_event = TRACEcreate("id", "event", TYPE_int);
TRACE_id_time = TRACEcreate("id", "time", TYPE_str);
TRACE_id_ticks = TRACEcreate("id", "ticks", TYPE_lng);
@@ -1073,30 +1093,29 @@
TRACE_id_writes == NULL ||
TRACE_id_thread == NULL ||
TRACE_id_user == NULL
- )
- cleanupProfiler();
- else
+ ) {
+ _cleanupProfiler();
+ } else {
TRACE_init = 1;
+ }
+}
+
+int
+initTrace(void)
+{
+ if (TRACE_init)
+ return 0; /* already initialized */
+ mal_set_lock(mal_contextLock, "profileLock");
+ _initTrace();
+ mal_unset_lock(mal_contextLock, "profileLock");
return TRACE_init ? 0 : -1;
}
-#define CLEANUPprofile(X) if (X) { BBPdecref((X)->batCacheid, TRUE);
(X)->batPersistence = TRANSIENT; } (X) = NULL;
str
-cleanupProfiler()
+cleanupProfiler(void)
{
mal_set_lock(mal_contextLock, "cleanup");
- CLEANUPprofile(TRACE_id_event);
- CLEANUPprofile(TRACE_id_time);
- CLEANUPprofile(TRACE_id_pc);
- CLEANUPprofile(TRACE_id_stmt);
- CLEANUPprofile(TRACE_id_type);
- CLEANUPprofile(TRACE_id_rbytes);
- CLEANUPprofile(TRACE_id_wbytes);
- CLEANUPprofile(TRACE_id_reads);
- CLEANUPprofile(TRACE_id_writes);
- CLEANUPprofile(TRACE_id_thread);
- CLEANUPprofile(TRACE_id_user);
- TRACE_init = 0;
+ _cleanupProfiler();
mal_unset_lock(mal_contextLock, "cleanup");
return MAL_SUCCEED;
}
@@ -1119,7 +1138,7 @@
BBPclear(TRACE_id_reads->batCacheid);
BBPclear(TRACE_id_writes->batCacheid);
TRACE_init = 0;
- initTrace();
+ _initTrace();
mal_unset_lock(mal_contextLock, "cleanup");
}
diff -r 218280d84a3e -r bdf37a61ba3a MonetDB5/src/modules/kernel/algebra.mx
--- a/MonetDB5/src/modules/kernel/algebra.mx Sun Aug 15 21:13:29 2010 +0200
+++ b/MonetDB5/src/modules/kernel/algebra.mx Sun Aug 15 22:31:47 2010 +0200
@@ -3388,20 +3388,17 @@
str
ALGtmarkp(int *result, int *bid, int *nr_parts, int *part_nr)
{
- int nr = *nr_parts;
#if SIZEOF_OID == 4
- int bits = 32;
+ int bits = 31;
#else
- int bits = 64;
+ int bits = 63;
#endif
oid base = 0;
assert(*part_nr < *nr_parts);
- while(nr > 0) {
- nr >>= 1;
- bits--;
- }
- base = (*part_nr)<<bits;
+ base = ((oid)1)<<bits;
+ base /= *nr_parts;
+ base *= *part_nr;
return ALGtmark(result, bid, &base);
}
@@ -3437,20 +3434,17 @@
str
ALGhmarkp(int *result, int *bid, int *nr_parts, int *part_nr)
{
- int nr = *nr_parts;
#if SIZEOF_OID == 4
- int bits = 32;
+ int bits = 31;
#else
- int bits = 64;
+ int bits = 63;
#endif
oid base = 0;
assert(*part_nr < *nr_parts);
- while(nr > 0) {
- nr >>= 1;
- bits--;
- }
- base = (*part_nr)<<bits;
+ base = ((oid)1)<<bits;
+ base /= *nr_parts;
+ base *= *part_nr;
return ALGmarkHead(result, bid, &base);
}
diff -r 218280d84a3e -r bdf37a61ba3a MonetDB5/src/optimizer/opt_mergetable.mx
--- a/MonetDB5/src/optimizer/opt_mergetable.mx Sun Aug 15 21:13:29 2010 +0200
+++ b/MonetDB5/src/optimizer/opt_mergetable.mx Sun Aug 15 22:31:47 2010 +0200
@@ -177,20 +177,20 @@
return 1;
}
/* perfect match */
- if (lub->value.val.lval == rub->value.val.lval &&
- llb->value.val.lval == rlb->value.val.lval)
+ if (lub->value.val.oval == rub->value.val.oval &&
+ llb->value.val.oval == rlb->value.val.oval)
return 1;
- if ((rub->value.val.lval != (lng)oid_nil &&
- rub->value.val.lval <= llb->value.val.lval) ||
- (lub->value.val.lval != (lng)oid_nil &&
- lub->value.val.lval <= rlb->value.val.lval))
+ if ((rub->value.val.oval != oid_nil &&
+ rub->value.val.oval <= llb->value.val.oval) ||
+ (lub->value.val.oval != oid_nil &&
+ lub->value.val.oval <= rlb->value.val.oval))
return 0;
- if ((rub->value.val.lval == (lng)oid_nil &&
- rlb->value.val.lval > lub->value.val.lval) ||
- (lub->value.val.lval == (lng)oid_nil &&
- llb->value.val.lval > rub->value.val.lval)) {
+ if ((rub->value.val.oval == oid_nil &&
+ rlb->value.val.oval > lub->value.val.oval) ||
+ (lub->value.val.oval == oid_nil &&
+ llb->value.val.oval > rub->value.val.oval)) {
return 0;
}
return 1;
@@ -207,20 +207,20 @@
return 1;
}
/* perfect match */
- if (lub->value.val.lval == rub->value.val.lval &&
- llb->value.val.lval == rlb->value.val.lval)
+ if (lub->value.val.oval == rub->value.val.oval &&
+ llb->value.val.oval == rlb->value.val.oval)
return 1;
- if ((rub->value.val.lval != (lng)oid_nil &&
- rub->value.val.lval <= llb->value.val.lval) ||
- (lub->value.val.lval != (lng)oid_nil &&
- lub->value.val.lval <= rlb->value.val.lval))
+ if ((rub->value.val.oval != oid_nil &&
+ rub->value.val.oval <= llb->value.val.oval) ||
+ (lub->value.val.oval != oid_nil &&
+ lub->value.val.oval <= rlb->value.val.oval))
return 0;
- if ((rub->value.val.lval == (lng)oid_nil &&
- rlb->value.val.lval > lub->value.val.lval) ||
- (lub->value.val.lval == (lng)oid_nil &&
- llb->value.val.lval > rub->value.val.lval)) {
+ if ((rub->value.val.oval == oid_nil &&
+ rlb->value.val.oval > lub->value.val.oval) ||
+ (lub->value.val.oval == oid_nil &&
+ llb->value.val.oval > rub->value.val.oval)) {
return 0;
}
return 1;
@@ -1005,7 +1005,7 @@
{
if (aggr == countRef || aggr == count_no_nilRef)
return sumRef;
- /* min/max/sum are fine */
+ /* min/max/sum/prod are fine */
return aggr;
}
@@ -1117,10 +1117,7 @@
s = newInstruction(mb,ASSIGNsymbol);
setModuleId(s,aggrRef);
- if (getFunctionId(p) == minRef || getFunctionId(p) == maxRef)
- setFunctionId(s, getFunctionId(p));
- else
- setFunctionId(s, sumRef);
+ setFunctionId(s, aggr_phase2(getFunctionId(p)));
getArg(s,0) = getArg(p,0);
s = pushArgument(mb, s, getArg(r,0));
pushInstruction(mb, s);
@@ -1620,7 +1617,8 @@
UNION(mirror().join()).
@c
- if (match > 0 && isMatJoinOp(p)) {
+ /* only handle simple joins, ie not range/band joins */
+ if (match > 0 && match <= 2 && isMatJoinOp(p)) {
m = isMATalias(getArg(p,1), mat, mtop);
n = isMATalias(getArg(p,2), mat, mtop);
if ((m = mat_join(mb, p, mat, mtop, m, n)) < 0)
@@ -1707,7 +1705,8 @@
getFunctionId(p) == count_no_nilRef ||
getFunctionId(p) == minRef ||
getFunctionId(p) == maxRef ||
- getFunctionId(p) == sumRef) &&
+ getFunctionId(p) == sumRef ||
+ getFunctionId(p) == prodRef) &&
((m=isMATalias(getArg(p,1), mat, mtop)) >= 0) &&
((n=isMATalias(getArg(p,2), mat, mtop)) >= 0) &&
((o=isMATalias(getArg(p,3), mat, mtop)) >= 0)) {
@@ -1731,7 +1730,8 @@
getFunctionId(p)== count_no_nilRef ||
getFunctionId(p)== minRef ||
getFunctionId(p)== maxRef ||
- getFunctionId(p)== sumRef) &&
+ getFunctionId(p)== sumRef ||
+ getFunctionId(p) == prodRef) &&
(m=isMATalias(getArg(p,1), mat, mtop)) >= 0){
mat_aggr(mb, p, mat, m);
actions++;
diff -r 218280d84a3e -r bdf37a61ba3a MonetDB5/src/optimizer/opt_prelude.mx
--- a/MonetDB5/src/optimizer/opt_prelude.mx Sun Aug 15 21:13:29 2010 +0200
+++ b/MonetDB5/src/optimizer/opt_prelude.mx Sun Aug 15 22:31:47 2010 +0200
@@ -140,6 +140,7 @@
opt_export str sqlplusRef;
opt_export str printRef;
opt_export str preludeRef;
+opt_export str prodRef;
opt_export str postludeRef;
opt_export str profilerRef;
opt_export str projectRef;
@@ -341,6 +342,7 @@
str sqlplusRef;
str printRef;
str preludeRef;
+str prodRef;
str postludeRef;
str profilerRef;
str projectRef;
@@ -538,6 +540,7 @@
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list