Changeset: dba20258c43f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/dba20258c43f
Branch: default
Log Message:

merged


diffs (truncated from 1006 to 300 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -50454,15 +50454,15 @@ command netcdf.test(X_0:str):int
 NCDFtest
 Returns number of variables in a given NetCDF dataset (file)
 oahash
-build_combined_table
-command oahash.build_combined_table(X_0:bat[:any_1], X_1:bat[:oid], X_2:bit) 
(X_3:bat[:oid], X_4:bat[:any_1])
-OAHASHbuild_tbl_cmbd
-Add the `key`-s with a `parent_slotid` to the hash table. Returns the 
`slot_id` per `key` and the updated `ht_sink`
+build
+pattern oahash.build(X_0:bat[:any_1], X_1:bat[:oid], X_2:bit) (X_3:bat[:oid], 
X_4:bat[:any_1])
+OAHASHbuild
+Add `keys` with `parents` to the `hashtable`. If `need_has_nil`, denote if 
`keys` contains NULL. Returns corresponding `gids` of the `keys` and the 
updated `hashtable`
 oahash
-build_table
-command oahash.build_table(X_0:bat[:any_1], X_1:bit) (X_2:bat[:oid], 
X_3:bat[:any_1])
-OAHASHbuild_tbl
-Add the `key`-s to the hash table. Returns the `slot_id` per `key` and the 
updated `ht_sink`
+build
+pattern oahash.build(X_0:bat[:any_1], X_1:bit) (X_2:bat[:oid], X_3:bat[:any_1])
+OAHASHbuild
+Add `keys` to the `hashtable`. If `need_has_nil`, denote if `keys` contains 
NULL. Returns corresponding `gids` of the `keys` and the updated `hashtable`
 oahash
 combined_mprobe
 command oahash.combined_mprobe(X_0:bat[:any_1], X_1:bat[:oid], X_2:bat[:oid], 
X_3:bat[:any_1], X_4:bit, X_5:bit) (X_6:bat[:oid], X_7:bat[:oid], X_8:bat[:bit])
diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -38639,15 +38639,15 @@ command netcdf.test(X_0:str):int
 NCDFtest
 Returns number of variables in a given NetCDF dataset (file)
 oahash
-build_combined_table
-command oahash.build_combined_table(X_0:bat[:any_1], X_1:bat[:oid], X_2:bit) 
(X_3:bat[:oid], X_4:bat[:any_1])
-OAHASHbuild_tbl_cmbd
-Add the `key`-s with a `parent_slotid` to the hash table. Returns the 
`slot_id` per `key` and the updated `ht_sink`
+build
+pattern oahash.build(X_0:bat[:any_1], X_1:bat[:oid], X_2:bit) (X_3:bat[:oid], 
X_4:bat[:any_1])
+OAHASHbuild
+Add `keys` with `parents` to the `hashtable`. If `need_has_nil`, denote if 
`keys` contains NULL. Returns corresponding `gids` of the `keys` and the 
updated `hashtable`
 oahash
-build_table
-command oahash.build_table(X_0:bat[:any_1], X_1:bit) (X_2:bat[:oid], 
X_3:bat[:any_1])
-OAHASHbuild_tbl
-Add the `key`-s to the hash table. Returns the `slot_id` per `key` and the 
updated `ht_sink`
+build
+pattern oahash.build(X_0:bat[:any_1], X_1:bit) (X_2:bat[:oid], X_3:bat[:any_1])
+OAHASHbuild
+Add `keys` to the `hashtable`. If `need_has_nil`, denote if `keys` contains 
NULL. Returns corresponding `gids` of the `keys` and the updated `hashtable`
 oahash
 combined_mprobe
 command oahash.combined_mprobe(X_0:bat[:any_1], X_1:bat[:oid], X_2:bat[:oid], 
X_3:bat[:any_1], X_4:bit, X_5:bit) (X_6:bat[:oid], X_7:bat[:oid], X_8:bat[:bit])
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -695,10 +695,12 @@ wrongtype(int t1, int t2)
 BAT *
 COLcopy2(BAT *b, int tt, bool writable, bool mayshare, role_t role)
 {
+       lng t0 = GDKusec();
        bool slowcopy = false;
        BAT *bn = NULL;
        BATiter bi;
        char strhash[GDK_STRHASHSIZE];
+       const char *algo = NULL;
 
        BATcheck(b, NULL);
 
@@ -832,6 +834,7 @@ COLcopy2(BAT *b, int tt, bool writable, 
                /* case (2): a void,void result => nothing to
                 * copy! */
                bn->theap->free = 0;
+               algo = "void";
        } else if (!slowcopy) {
                /* case (3): just copy the heaps */
                if (bn->tvheap) {
@@ -843,6 +846,7 @@ COLcopy2(BAT *b, int tt, bool writable, 
                                        bn->tvheap = bi.vh;
                                        bn->tvkey = bi.vkey;
                                        bn->tascii = bi.ascii;
+                                       algo = "share vheap, memcpy heap";
                                }
                        } else {
                                if (HEAPextend(bn->tvheap, bi.vhfree, true) != 
GDK_SUCCEED)
@@ -854,6 +858,7 @@ COLcopy2(BAT *b, int tt, bool writable, 
                                bn->tascii = bi.ascii;
                                if (ATOMstorage(b->ttype) == TYPE_str && 
bi.vhfree >= GDK_STRHASHSIZE)
                                        memcpy(bn->tvheap->base, strhash, 
GDK_STRHASHSIZE);
+                               algo = "memcpy vheap and heap";
                        }
                }
                memcpy(bn->theap->base, bi.base, bi.hfree);
@@ -867,7 +872,7 @@ COLcopy2(BAT *b, int tt, bool writable, 
                        bn->batCapacity = (BUN) (bn->theap->size >> bn->tshift);
                else
                        bn->batCapacity = 0;
-       } else if (tt != TYPE_void || ATOMextern(tt)) {
+       } else if (ATOMextern(tt)) {
                /* case (4): one-by-one BUN insert (really slow) */
                QryCtx *qry_ctx = MT_thread_get_qry_ctx();
 
@@ -880,7 +885,8 @@ COLcopy2(BAT *b, int tt, bool writable, 
                }
                TIMEOUT_CHECK(qry_ctx, 
GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed, qry_ctx));
                bn->theap->dirty |= bi.count > 0;
-       } else if (tt != TYPE_void && bi.type == TYPE_void) {
+               algo = "insert values";
+       } else if (bi.type == TYPE_void) {
                /* case (4): optimized for unary void
                 * materialization */
                oid cur = bi.tseq, *dst = (oid *) Tloc(bn, 0);
@@ -892,6 +898,7 @@ COLcopy2(BAT *b, int tt, bool writable, 
                }
                bn->theap->free = bi.count * sizeof(oid);
                bn->theap->dirty |= bi.count > 0;
+               algo = "materialize void";
        } else if (ATOMstorage(bi.type) == TYPE_msk) {
                /* convert number of bits to number of bytes,
                 * and round the latter up to a multiple of
@@ -899,11 +906,13 @@ COLcopy2(BAT *b, int tt, bool writable, 
                bn->theap->free = ((bi.count + 31) / 32) * 4;
                memcpy(Tloc(bn, 0), bi.base, bn->theap->free);
                bn->theap->dirty |= bi.count > 0;
+               algo = "memcpy msk";
        } else {
                /* case (4): optimized for simple array copy */
                bn->theap->free = bi.count << bn->tshift;
                memcpy(Tloc(bn, 0), bi.base, bn->theap->free);
                bn->theap->dirty |= bi.count > 0;
+               algo = "memcpy heap";
        }
        /* copy all properties (size+other) from the source bat */
        BATsetcount(bn, bi.count);
@@ -976,8 +985,8 @@ COLcopy2(BAT *b, int tt, bool writable, 
        bat_iterator_end(&bi);
        if (!writable)
                bn->batRestricted = BAT_READ;
-       TRC_DEBUG(ALGO, ALGOBATFMT " -> " ALGOBATFMT "\n",
-                 ALGOBATPAR(b), ALGOBATPAR(bn));
+       TRC_DEBUG(ALGO, ALGOBATFMT " -> " ALGOBATFMT " (%s) " LLFMT " usec\n",
+                 ALGOBATPAR(b), ALGOBATPAR(bn), algo, GDKusec() - t0);
        return bn;
   bunins_failed:
        bat_iterator_end(&bi);
diff --git a/gdk/gdk_sketch.c b/gdk/gdk_sketch.c
--- a/gdk/gdk_sketch.c
+++ b/gdk/gdk_sketch.c
@@ -9,6 +9,7 @@
  */
 
 #include "gdk.h"
+#include "gdk_private.h"
 #if defined(HAVE_GETENTROPY) && defined(HAVE_SYS_RANDOM_H)
 #include <sys/random.h>
 #endif
@@ -180,6 +181,7 @@ int
 sketch_populate(BAT *b, BATiter *bi, struct canditer *bci,
                uint8_t cnting_sketch[BUCKETS][CLZ_BUCKETS])
 {
+       lng t0 = GDKusec();
        gdk_return rc = GDK_SUCCEED;
        QryCtx *qry_ctx = MT_thread_get_qry_ctx();
 
@@ -229,6 +231,8 @@ sketch_populate(BAT *b, BATiter *bi, str
        if (bi == NULL)
                bat_iterator_end(&n_bi);
 
+       TRC_DEBUG(ALGO, ALGOBATFMT " " LLFMT " usec\n", ALGOBATPAR(b),
+                 GDKusec() - t0);
        return rc;
 }
 
@@ -247,6 +251,7 @@ sketch_populate(BAT *b, BATiter *bi, str
 double
 bat_guess_uniques(BAT *b, BATiter *bi, struct canditer *bci)
 {
+       lng t0 = GDKusec();
        uint8_t cnting_sketch[BUCKETS][CLZ_BUCKETS] = {0};
        double unique_guess = 0;
 
@@ -258,5 +263,7 @@ bat_guess_uniques(BAT *b, BATiter *bi, s
                unique_guess = sketch_estimate(cnting_sketch);
 
        b->tunique_est = unique_guess;
+       TRC_DEBUG(ALGO, ALGOBATFMT " " LLFMT " usec\n", ALGOBATPAR(b),
+                 GDKusec() - t0);
        return unique_guess;
 }
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
@@ -695,11 +695,16 @@ runMALsequence(Client cntxt, MalBlkPtr m
                                                                          
"address of pattern %s.%s missing",
                                                                          
pci->modname, pci->fcnname);
                        } else {
+                               lng t0 = GDKusec();
                                TRC_INFO(ALGO, "calling %s.%s\n",
                                                 pci->modname ? pci->modname : 
"<null>",
                                                 pci->fcnname ? pci->fcnname : 
"<null>");
                                ret = (*(str (*) (Client, MalBlkPtr, MalStkPtr, 
InstrPtr)) pci->
                                           fcn) (cntxt, mb, stk, pci);
+                               TRC_DEBUG(ALGO, "done calling %s.%s " LLFMT " 
usec\n",
+                                                 pci->modname ? pci->modname : 
"<null>",
+                                                 pci->fcnname ? pci->fcnname : 
"<null>",
+                                                 GDKusec() - t0);
 #ifndef NDEBUG
                                if (ret == MAL_SUCCEED) {
                                        /* check that the types of actual 
results match
@@ -725,11 +730,16 @@ runMALsequence(Client cntxt, MalBlkPtr m
 #endif
                        }
                        break;
-               case CMDcall:
+               case CMDcall: {
+                       lng t0 = GDKusec();
                        TRC_DEBUG(ALGO, "calling %s.%s\n",
                                          pci->modname ? pci->modname : 
"<null>",
                                          pci->fcnname ? pci->fcnname : 
"<null>");
                        ret = malCommandCall(cntxt, stk, pci);
+                               TRC_DEBUG(ALGO, "done calling %s.%s " LLFMT " 
usec\n",
+                                                 pci->modname ? pci->modname : 
"<null>",
+                                                 pci->fcnname ? pci->fcnname : 
"<null>",
+                                                 GDKusec() - t0);
 #ifndef NDEBUG
                        if (ret == MAL_SUCCEED) {
                                /* check that the types of actual results match
@@ -752,6 +762,7 @@ runMALsequence(Client cntxt, MalBlkPtr m
                        }
 #endif
                        break;
+               }
                case FCNcall: {
                        /*
                         * MAL function calls are relatively expensive,
diff --git a/monetdb5/modules/mal/pp_hash.c b/monetdb5/modules/mal/pp_hash.c
--- a/monetdb5/modules/mal/pp_hash.c
+++ b/monetdb5/modules/mal/pp_hash.c
@@ -11,6 +11,7 @@
 #include "monetdb_config.h"
 #include "gdk.h"
 #include "gdk_time.h"
+#include "mal_arguments.h"
 #include "mal_interpreter.h"
 #include "mal_instruction.h"
 #include "mal_exception.h"
@@ -560,7 +561,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
 
 /* ***** HASH OPERATORS ***** */
 
-#define BATaprep_heap(BT, SB, SK, FName) \
+#define aprep_heap(BT, SB, SK) \
        do { \
                MT_lock_set(&SB->theaplock); \
                MT_lock_set(&BT->theaplock); \
@@ -568,32 +569,32 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                        MT_lock_unset(&BT->theaplock); \
                        MT_lock_unset(&SB->theaplock); \
                        local_storage = true; \
-                       pipeline_lock(p); \
+                       pipeline_lock(pl); \
                        if (!SK->allocators) { \
-                               SK->allocators = 
(allocator**)GDKzalloc(p->p->nr_workers*sizeof(allocator*)); \
+                               SK->allocators = 
(allocator**)GDKzalloc(pl->p->nr_workers*sizeof(allocator*)); \
                                if (!SK->allocators) { \
-                                       pipeline_unlock(p); \
-                                       err = createException(MAL, FName, 
SQLSTATE(HY013) MAL_MALLOC_FAIL); \
+                                       pipeline_unlock(pl); \
+                                       err = createException(MAL, 
"oahash.build", SQLSTATE(HY013) MAL_MALLOC_FAIL); \
                                        goto error; \
                                } else { \
-                                       SK->nr_allocators = p->p->nr_workers; \
+                                       SK->nr_allocators = pl->p->nr_workers; \
                                } \
                        } \
-                       pipeline_unlock(p); \
-                       assert(p->wid < p->p->nr_workers); \
-                       if (!SK->allocators[p->wid]) { \
+                       pipeline_unlock(pl); \
+                       assert(pl->wid < pl->p->nr_workers); \
+                       if (!SK->allocators[pl->wid]) { \
                                char name[MT_NAME_LEN]; \
-                               snprintf(name, sizeof(name), "pp%d", p->wid); \
-                               SK->allocators[p->wid] = create_allocator(name, 
false); \
-                               if (!SK->allocators[p->wid]) { \
-                                       err = createException(MAL, FName, 
SQLSTATE(HY013) MAL_MALLOC_FAIL); \
+                               snprintf(name, sizeof(name), "pp%d", pl->wid); \
+                               SK->allocators[pl->wid] = 
create_allocator(name, false); \
+                               if (!SK->allocators[pl->wid]) { \
+                                       err = createException(MAL, 
"oahash.build", SQLSTATE(HY013) MAL_MALLOC_FAIL); \
                                        goto error; \
                                } \
                        } \
                } else if (BATcount(BT) && BATcount(SB) == 0 && 
SB->tvheap->parentid == SB->batCacheid) { \
                        MT_lock_unset(&BT->theaplock); \
                        MT_lock_unset(&SB->theaplock); \
-                       BATswap_heaps(SB, BT, p); \
+                       BATswap_heaps(SB, BT, pl); \
                } else if (SB->tvheap->parentid != BT->tvheap->parentid) { \
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to