Changeset: 5fa9dd6928e0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5fa9dd6928e0
Modified Files:
        gdk/gdk_align.c
        gdk/gdk_bbp.c
        gdk/gdk_hash.c
        gdk/gdk_imprints.c
        gdk/gdk_orderidx.c
        gdk/gdk_storage.c
        gdk/gdk_system.c
        gdk/gdk_system.h
Branch: default
Log Message:

Merge with Aug2018 branch.


diffs (truncated from 409 to 300 lines):

diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -123,10 +123,7 @@ VIEWcreate(oid seq, BAT *b)
                bn->theap.parentid = tp;
        BATinit_idents(bn);
        bn->batRestricted = BAT_READ;
-       if (!tp || isVIEW(b))
-               bn->thash = NULL;
-       else
-               bn->thash = b->thash;
+       bn->thash = NULL;
        /* imprints are shared, but the check is dynamic */
        bn->timprints = NULL;
        /* Order OID index */
@@ -241,10 +238,6 @@ VIEWunlink(BAT *b)
                if (tpb && b->tprops && b->tprops == tpb->tprops)
                        b->tprops = NULL;
 
-               /* unlink hash accelerators shared with parent */
-               if (tpb && b->thash && b->thash == tpb->thash)
-                       b->thash = NULL;
-
                /* unlink imprints shared with parent */
                if (tpb && b->timprints && b->timprints == tpb->timprints)
                        b->timprints = NULL;
@@ -405,9 +398,6 @@ VIEWbounds(BAT *b, BAT *view, BUN l, BUN
        } else {
                view->tnokey[0] = view->tnokey[1] = 0;
        }
-       /* slices are unequal to their parents; cannot use accs */
-       if (b->thash == view->thash)
-               view->thash = NULL;
 }
 
 /*
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1814,7 +1814,7 @@ BBPdump(void)
                                }
                        }
                }
-               if (b->thash && b->thash != (Hash *) -1) {
+               if (b->thash && b->thash != (Hash *) 1) {
                        fprintf(stderr,
                                " Thash=[%zu,%zu]",
                                HEAPmemsize(&b->thash->heap),
@@ -2394,12 +2394,6 @@ incref(bat i, bool logical, bool lock)
                if (tp) {
                        assert(pb != NULL);
                        b->theap.base = pb->theap.base + (size_t) b->theap.base;
-                       /* if we shared the hash before, share it
-                        * again note that if the parent's hash is
-                        * destroyed, we also don't have a hash
-                        * anymore */
-                       if (b->thash == (Hash *) -1)
-                               b->thash = pb->thash;
                }
                /* done loading, release descriptor */
                BBP_status_off(i, BBPLOADING, "BBPfix");
@@ -2494,12 +2488,6 @@ decref(bat i, bool logical, bool release
                        if (b && refs == 0) {
                                if ((tp = b->theap.parentid) != 0)
                                        b->theap.base = (char *) (b->theap.base 
- BBP_cache(tp)->theap.base);
-                               /* if a view shared the hash with its
-                                * parent, indicate this, but only if
-                                * view isn't getting destroyed */
-                               if (tp && b->thash &&
-                                   b->thash == BBP_cache(tp)->thash)
-                                       b->thash = (Hash *) -1;
                                tvp = VIEWvtparent(b);
                        }
                }
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -256,26 +256,34 @@ BAThashsync(void *arg)
        MT_lock_set(&GDKhashLock(b->batCacheid));
        if (b->thash != NULL) {
                Heap *hp = &b->thash->heap;
-               if (HEAPsave(hp, hp->filename, NULL) == GDK_SUCCEED &&
-                   (fd = GDKfdlocate(hp->farmid, hp->filename, "rb+", NULL)) 
>= 0) {
-                       ((size_t *) hp->base)[0] |= 1 << 24;
-                       if (write(fd, hp->base, SIZEOF_SIZE_T) >= 0) {
-                               failed = ""; /* not failed */
-                               if (!(GDKdebug & NOSYNCMASK)) {
+               if (HEAPsave(hp, hp->filename, NULL) == GDK_SUCCEED) {
+                       if (hp->storage == STORE_MEM) {
+                               if ((fd = GDKfdlocate(hp->farmid, hp->filename, 
"rb+", NULL)) >= 0) {
+                                       ((size_t *) hp->base)[0] |= (size_t) 1 
<< 24;
+                                       if (write(fd, hp->base, SIZEOF_SIZE_T) 
>= 0) {
+                                               failed = ""; /* not failed */
+                                               if (!(GDKdebug & NOSYNCMASK)) {
 #if defined(NATIVE_WIN32)
-                                       _commit(fd);
+                                                       _commit(fd);
 #elif defined(HAVE_FDATASYNC)
-                                       fdatasync(fd);
+                                                       fdatasync(fd);
 #elif defined(HAVE_FSYNC)
-                                       fsync(fd);
+                                                       fsync(fd);
 #endif
+                                               }
+                                       } else {
+                                               perror("write hash");
+                                       }
+                                       close(fd);
                                }
                        } else {
-                               perror("write hash");
+                               ((size_t *) hp->base)[0] |= (size_t) 1 << 24;
+                               if (!(GDKdebug & NOSYNCMASK) &&
+                                   MT_msync(hp->base, SIZEOF_SIZE_T) < 0)
+                                       ((size_t *) hp->base)[0] &= ~((size_t) 
1 << 24);
                        }
-                       close(fd);
+                       ALGODEBUG fprintf(stderr, "#BAThash: persisting hash %s 
(" LLFMT " usec)%s\n", hp->filename, GDKusec() - t0, failed);
                }
-               ALGODEBUG fprintf(stderr, "#BAThash: persisting hash %s (" 
LLFMT " usec)%s\n", hp->filename, GDKusec() - t0, failed);
        }
        MT_lock_unset(&GDKhashLock(b->batCacheid));
        BBPunfix(b->batCacheid);
@@ -574,7 +582,7 @@ BAThash(BAT *b)
                        MT_Id tid;
                        BBPfix(b->batCacheid);
                        if (MT_create_thread(&tid, BAThashsync, b,
-                                            MT_THR_REALLY_DETACHED) < 0) {
+                                            MT_THR_DETACHED) < 0) {
                                /* couldn't start thread: clean up */
                                BBPunfix(b->batCacheid);
                        }
@@ -649,7 +657,7 @@ HASHdestroy(BAT *b)
                        if (p)
                                hp = BBP_cache(p);
 
-                       if ((!hp || hs != hp->thash) && hs != (Hash *) -1) {
+                       if (!hp || hs != hp->thash) {
                                ALGODEBUG if (*(size_t *) hs->heap.base & (1 << 
24))
                                        fprintf(stderr, "#HASHdestroy: removing 
persisted hash %d\n", b->batCacheid);
                                HEAPfree(&hs->heap, true);
@@ -662,35 +670,14 @@ HASHdestroy(BAT *b)
 void
 HASHfree(BAT *b)
 {
-       int err = 0;
        if (b) {
                MT_lock_set(&GDKhashLock(b->batCacheid));
-               if (b->thash && b->thash != (Hash *) -1) {
-                       if (b->thash != (Hash *) 1) {
-                               if (b->thash->heap.storage == STORE_MEM &&
-                                   b->thash->heap.dirty) {
-                                       if (GDKsave(b->thash->heap.farmid,
-                                                   b->thash->heap.filename,
-                                                   NULL,
-                                                   b->thash->heap.base,
-                                                   b->thash->heap.free,
-                                                   STORE_MEM,
-                                                   false) != GDK_SUCCEED) {
-                                               /* if saving failed, remove */
-                                               
GDKunlink(BBPselectfarm(b->batRole, b->ttype, hashheap),
-                                                         BATDIR,
-                                                         
BBP_physical(b->batCacheid),
-                                                         "thash");
-                                               err = 1;
-                                       }
-                                       b->thash->heap.dirty = FALSE;
-                               }
-                               HEAPfree(&b->thash->heap, false);
-                               GDKfree(b->thash);
-                               b->thash = err ? NULL : (Hash *) 1;
-                       }
-               } else {
-                       b->thash = NULL;
+               if (b->thash && b->thash != (Hash *) 1) {
+                       bool dirty = b->thash->heap.dirty;
+
+                       HEAPfree(&b->thash->heap, dirty);
+                       GDKfree(b->thash);
+                       b->thash = dirty ? NULL : (Hash *) 1;
                }
                MT_lock_unset(&GDKhashLock(b->batCacheid));
        }
diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c
--- a/gdk/gdk_imprints.c
+++ b/gdk/gdk_imprints.c
@@ -273,36 +273,49 @@ BATimpsync(void *arg)
        Imprints *imprints;
        int fd;
        lng t0 = 0;
+       const char *failed = " failed";
 
        ALGODEBUG t0 = GDKusec();
 
        MT_lock_set(&GDKimprintsLock(b->batCacheid));
        if ((imprints = b->timprints) != NULL) {
-               if (HEAPsave(&imprints->imprints, BBP_physical(b->batCacheid),
-                            "timprints") == GDK_SUCCEED &&
-                   (fd = GDKfdlocate(imprints->imprints.farmid,
-                                     BBP_physical(b->batCacheid), "rb+",
-                                     "timprints")) >= 0) {
-                       /* add version number */
-                       ((size_t *) imprints->imprints.base)[0] |= (size_t) 
IMPRINTS_VERSION << 8;
-                       /* sync-on-disk checked bit */
-                       ((size_t *) imprints->imprints.base)[0] |= (size_t) 1 
<< 16;
-                       if (write(fd, imprints->imprints.base, sizeof(size_t)) 
< 0)
-                               perror("write imprints");
-                       if (!(GDKdebug & NOSYNCMASK)) {
+               Heap *hp = &imprints->imprints;
+               if (HEAPsave(hp, hp->filename, NULL) == GDK_SUCCEED) {
+                       if (hp->storage == STORE_MEM) {
+                               if ((fd = GDKfdlocate(hp->farmid, hp->filename, 
"rb+", NULL)) >= 0) {
+                                       /* add version number */
+                                       ((size_t *) hp->base)[0] |= (size_t) 
IMPRINTS_VERSION << 8;
+                                       /* sync-on-disk checked bit */
+                                       ((size_t *) hp->base)[0] |= (size_t) 1 
<< 16;
+                                       if (write(fd, hp->base, SIZEOF_SIZE_T) 
>= 0) {
+                                               failed = ""; /* not failed */
+                                               if (!(GDKdebug & NOSYNCMASK)) {
 #if defined(NATIVE_WIN32)
-                               _commit(fd);
+                                                       _commit(fd);
 #elif defined(HAVE_FDATASYNC)
-                               fdatasync(fd);
+                                                       fdatasync(fd);
 #elif defined(HAVE_FSYNC)
-                               fsync(fd);
+                                                       fsync(fd);
 #endif
+                                               }
+                                       } else {
+                                               perror("write hash");
+                                       }
+                                       close(fd);
+                               }
+                       } else {
+                               /* add version number */
+                               ((size_t *) hp->base)[0] |= (size_t) 
IMPRINTS_VERSION << 8;
+                               /* sync-on-disk checked bit */
+                               ((size_t *) hp->base)[0] |= (size_t) 1 << 16;
+                               if (!(GDKdebug & NOSYNCMASK) &&
+                                   MT_msync(hp->base, SIZEOF_SIZE_T) < 0)
+                                       ((size_t *) hp->base)[0] &= ~((size_t) 
IMPRINTS_VERSION << 8);
                        }
-                       close(fd);
                        ALGODEBUG fprintf(stderr, "#BATimpsync(" ALGOBATFMT "): 
"
                                          "imprints persisted "
-                                         "(" LLFMT " usec)\n", ALGOBATPAR(b),
-                                         GDKusec() - t0);
+                                         "(" LLFMT " usec)%s\n", ALGOBATPAR(b),
+                                         GDKusec() - t0, failed);
                }
        }
        MT_lock_unset(&GDKimprintsLock(b->batCacheid));
@@ -508,7 +521,7 @@ BATimprints(BAT *b)
                    !b->theap.dirty) {
                        MT_Id tid;
                        BBPfix(b->batCacheid);
-                       if (MT_create_thread(&tid, BATimpsync, b, 
MT_THR_REALLY_DETACHED) < 0)
+                       if (MT_create_thread(&tid, BATimpsync, b, 
MT_THR_DETACHED) < 0)
                                BBPunfix(b->batCacheid);
                }
        }
diff --git a/gdk/gdk_orderidx.c b/gdk/gdk_orderidx.c
--- a/gdk/gdk_orderidx.c
+++ b/gdk/gdk_orderidx.c
@@ -20,32 +20,42 @@ BATidxsync(void *arg)
        Heap *hp;
        int fd;
        lng t0 = 0;
+       const char *failed = " failed";
 
        ALGODEBUG t0 = GDKusec();
 
        MT_lock_set(&GDKhashLock(b->batCacheid));
        if ((hp = b->torderidx) != NULL) {
-               if (HEAPsave(hp, hp->filename, NULL) == GDK_SUCCEED &&
-                   (fd = GDKfdlocate(hp->farmid, hp->filename, "rb+", NULL)) 
>= 0) {
-                       ((oid *) hp->base)[0] |= (oid) 1 << 24;
-                       if (write(fd, hp->base, SIZEOF_SIZE_T) >= 0) {
-                               if (!(GDKdebug & NOSYNCMASK)) {
+               if (HEAPsave(hp, hp->filename, NULL) == GDK_SUCCEED) {
+                       if (hp->storage == STORE_MEM) {
+                               if ((fd = GDKfdlocate(hp->farmid, hp->filename, 
"rb+", NULL)) >= 0) {
+                                       ((oid *) hp->base)[0] |= (oid) 1 << 24;
+                                       if (write(fd, hp->base, SIZEOF_OID) >= 
0) {
+                                               failed = ""; /* not failed */
+                                               if (!(GDKdebug & NOSYNCMASK)) {
 #if defined(NATIVE_WIN32)
-                                       _commit(fd);
+                                                       _commit(fd);
 #elif defined(HAVE_FDATASYNC)
-                                       fdatasync(fd);
+                                                       fdatasync(fd);
 #elif defined(HAVE_FSYNC)
-                                       fsync(fd);
+                                                       fsync(fd);
 #endif
+                                               }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to