Changeset: 0c743bc4887a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0c743bc4887a
Modified Files:
        monetdb5/modules/mal/heapn.c
        monetdb5/modules/mal/pipeline.h
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/rel_physical.c
Branch: default
Log Message:

make topn run concurrently in more cases.


diffs (100 lines):

diff --git a/monetdb5/modules/mal/heapn.c b/monetdb5/modules/mal/heapn.c
--- a/monetdb5/modules/mal/heapn.c
+++ b/monetdb5/modules/mal/heapn.c
@@ -1952,8 +1952,6 @@ static str
 HEAPorder2(Client ctx, bat *rid, bat *hb, lng *O)
 {
        size_t offset = (size_t)*O;
-       if (offset == 0)
-               offset++;
        return HEAPorder(ctx, rid, hb, offset);
 }
 
diff --git a/monetdb5/modules/mal/pipeline.h b/monetdb5/modules/mal/pipeline.h
--- a/monetdb5/modules/mal/pipeline.h
+++ b/monetdb5/modules/mal/pipeline.h
@@ -26,7 +26,7 @@
 #define pipeline_get_thread_private_pipeline() MT_thread_getdata()
 #define pipeline_set_thread_private_pipeline(p) MT_thread_setdata(p)
 
-#define SLICE_SIZE (2*1024)
+#define SLICE_SIZE (128*1024)
 
 // TODO a better way to define/add/register sinks, similar to types
 #define PIPELINE_IO_HASH_TABLE 1
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
@@ -5035,6 +5035,8 @@ rel2bin_select(backend *be, sql_rel *rel
                        return predicate;
                assert(0);
        }
+       if (rel->parallel && !be->pp)
+               sub = rel2bin_slicer_pp(be, sub);
        en = rel->exps->h;
        if (!sub && predicate) {
                list *l = sa_list(sql->sa);
@@ -7974,8 +7976,14 @@ rel2bin_materialize(backend *be, sql_rel
        bool is_materialized = false;
 
        if (is_topn(r->op)) {
+               sql_rel *o = r;
                r = r->l;
                is_materialized = true;
+               if (o->parallel) {
+                       s = subrel_bin(be, rel, refs);
+                       s = subrel_project(be, s, refs, rel);
+                       return s;
+               }
        }
 
        list *shared = NULL;
diff --git a/sql/backends/monet5/rel_physical.c 
b/sql/backends/monet5/rel_physical.c
--- a/sql/backends/monet5/rel_physical.c
+++ b/sql/backends/monet5/rel_physical.c
@@ -800,12 +800,9 @@ rel_pipeline(visitor *v, sql_rel *rel, b
                res = rel_pipeline(v, rel->l, pp_useful, pp_useful?SPB:0);
                if (pp_useful && res) { /* topn is blocking */
                        rel->parallel = 1;
-                       if (pb) { /* nested */
-                               rel_dup(rel);
-                               res = 0;
-                               rel->partition = 1;
-                       }
-                       res = EPB;
+                       rel_dup(rel);
+                       res = 0;
+                       rel->partition = 1;
                } else if (pb) {
                        rel->spb = 1;
                }
@@ -835,8 +832,7 @@ rel_pipeline(visitor *v, sql_rel *rel, b
                                if (res && p && p->op == op_project && 
exps_have_unsafe(p->exps, 1, false)) {
                                        rel_dup(rel);
                                        res = 0;
-                               } else
-                               if (pb) {
+                               } else if (pb) {
                                        sql_rel *l = rel->l;
                                        if (!res && l && is_groupby(l->op) && 
l->l) {
                                                sql_rel *p = l->l;
@@ -846,6 +842,10 @@ rel_pipeline(visitor *v, sql_rel *rel, b
                                                        res = SPB;
                                                }
                                        }
+                                       if (!res && is_select(rel->op)) {
+                                               rel->parallel = 1;
+                                               res = SPB;
+                                       }
                                        if (rel->spb)
                                                res = SPB;
                                }
@@ -939,8 +939,6 @@ rel_pipeline(visitor *v, sql_rel *rel, b
                        int started_pb = 0;
                        if (rel_is_ref(rel))
                                pb = 0;
-                       else
-                               pb |= materialize;
                        for(node *n = rels->h; n; n = n->next) {
                                int lres = rel_pipeline(v, n->data, false, 
pb?SPB:0);
                                if (lres == EPB) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to