MonetDB: Jun2023 - Fixed condition variable variant of semaphore...
Changeset: 164dee1f60ee for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/164dee1f60ee Modified Files: gdk/gdk_system.h Branch: Jun2023 Log Message: Fixed condition variable variant of semaphores implementation. diffs (41 lines): diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h --- a/gdk/gdk_system.h +++ b/gdk/gdk_system.h @@ -673,7 +673,7 @@ typedef struct { /* simulate semaphores using mutex and condition variable */ typedef struct { - int cnt; + int cnt, wakeups; pthread_mutex_t mutex; pthread_cond_t cond; char name[MT_NAME_LEN]; @@ -683,6 +683,7 @@ typedef struct { do {\ strcpy_len((s)->name, (n), sizeof((s)->name)); \ (s)->cnt = (nr);\ + (s)->wakeups = 0; \ pthread_mutex_init(&(s)->mutex, 0); \ pthread_cond_init(&(s)->cond, 0); \ } while (0) @@ -696,7 +697,8 @@ typedef struct { #define MT_sema_up(s) \ do {\ pthread_mutex_lock(&(s)->mutex);\ - if ((s)->cnt++ < 0) { \ + if (++(s)->cnt <= 0) { \ + (s)->wakeups++; \ pthread_cond_signal(&(s)->cond);\ } \ pthread_mutex_unlock(&(s)->mutex); \ @@ -711,8 +713,9 @@ typedef struct { do {\ pthread_cond_wait(&(s)->cond, \ &(s)->mutex); \ - } while ((s)->cnt < 0); \ + } while ((s)->wakeups < 1); \ MT_thread_setsemawait(NULL);\ + (s)->wakeups--; \ pthread_mutex_unlock(&(s)->mutex); \ } \ TRC_DEBUG(TEM, "Sema %s down complete\n", (s)->name); \ ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Dec2023 - Merge with Jun2023 branch.
Changeset: 9e98971ed85f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/9e98971ed85f Modified Files: gdk/gdk_system.h Branch: Dec2023 Log Message: Merge with Jun2023 branch. diffs (41 lines): diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h --- a/gdk/gdk_system.h +++ b/gdk/gdk_system.h @@ -686,7 +686,7 @@ typedef struct { /* simulate semaphores using mutex and condition variable */ typedef struct { - int cnt; + int cnt, wakeups; pthread_mutex_t mutex; pthread_cond_t cond; char name[MT_NAME_LEN]; @@ -696,6 +696,7 @@ typedef struct { do {\ strcpy_len((s)->name, (n), sizeof((s)->name)); \ (s)->cnt = (nr);\ + (s)->wakeups = 0; \ pthread_mutex_init(&(s)->mutex, 0); \ pthread_cond_init(&(s)->cond, 0); \ } while (0) @@ -709,7 +710,8 @@ typedef struct { #define MT_sema_up(s) \ do {\ pthread_mutex_lock(&(s)->mutex);\ - if ((s)->cnt++ < 0) { \ + if (++(s)->cnt <= 0) { \ + (s)->wakeups++; \ pthread_cond_signal(&(s)->cond);\ } \ pthread_mutex_unlock(&(s)->mutex); \ @@ -724,8 +726,9 @@ typedef struct { do {\ pthread_cond_wait(&(s)->cond, \ &(s)->mutex); \ - } while ((s)->cnt < 0); \ + } while ((s)->wakeups < 1); \ MT_thread_setsemawait(NULL);\ + (s)->wakeups--; \ pthread_mutex_unlock(&(s)->mutex); \ } \ TRC_DEBUG(TEM, "Sema %s down complete\n", (s)->name); \ ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jun2023 - Use `free' value of to-be-copied heap to allo...
Changeset: 12f9da627389 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/12f9da627389 Modified Files: gdk/gdk_batop.c Branch: Jun2023 Log Message: Use `free' value of to-be-copied heap to allocate size, not its `size'. diffs (12 lines): diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -139,7 +139,7 @@ insert_string_bat(BAT *b, BATiter *ni, s } MT_lock_set(&b->theaplock); - if (HEAPgrow(&b->tvheap, toff + ni->vh->size, force) != GDK_SUCCEED) { + if (HEAPgrow(&b->tvheap, toff + ni->vhfree, force) != GDK_SUCCEED) { MT_lock_unset(&b->theaplock); return GDK_FAIL; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Dec2023 - Perform the JSON upgrade by creating new heaps
Changeset: 6173f57cb268 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/6173f57cb268 Modified Files: gdk/gdk_bbp.c monetdb5/modules/atoms/json.c Branch: Dec2023 Log Message: Perform the JSON upgrade by creating new heaps diffs (290 lines): diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -1476,21 +1476,199 @@ movestrbats(void) #endif #ifdef GDKLIBRARY_JSON +static gdk_return jsonupgradebat(BAT *b, + json_storage_conversion fixJSONStorage) { + const char *nme = BBP_physical(b->batCacheid); + char *srcdir = GDKfilepath(NOFARM, BATDIR, nme, NULL); + +if (srcdir == NULL) { + TRC_CRITICAL(GDK, "GDKfilepath failed\n"); + return GDK_FAIL; +} + + char *s; + if ((s = strrchr(srcdir, DIR_SEP)) != NULL) + *s = 0; +const char *bnme; +if ((bnme = strrchr(nme, DIR_SEP)) != NULL) { + bnme++; +} else { + bnme = nme; +} + +long_str filename; + snprintf(filename, sizeof(filename), "BACKUP%c%s", DIR_SEP, bnme); + + /* A json column should not normally have any index structures */ + HASHdestroy(b); + IMPSdestroy(b); + OIDXdestroy(b); + PROPdestroy(b); + STRMPdestroy(b); + RTREEdestroy(b); + + /* bakup the current heaps */ + if (GDKmove(b->theap->farmid, srcdir, bnme, "tail", +BAKDIR, bnme, "tail", false) != GDK_SUCCEED) { +GDKfree(srcdir); + TRC_CRITICAL(GDK, "cannot make backup of %s.tail\n", nme); + return GDK_FAIL; +} + GDKclrerr(); +if (GDKmove(b->theap->farmid, srcdir, bnme, "theap", +BAKDIR, bnme, "theap", true) != GDK_SUCCEED) { +GDKfree(srcdir); + TRC_CRITICAL(GDK, "cannot make backup of %s.theap\n", nme); + return GDK_FAIL; +} + + +/* load the old heaps */ +Heap h1 = *b->theap; +h1.base = NULL; +h1.dirty = false; +strconcat_len(h1.filename, sizeof(h1.filename), filename, ".tail", NULL); +if (HEAPload(&h1, filename, "tail", false) != GDK_SUCCEED) { +GDKfree(srcdir); +TRC_CRITICAL(GDK, "loading old tail heap " + "for BAT %d failed\n", b->batCacheid); + return GDK_FAIL; +} + +Heap vh1 = *b->tvheap; +vh1.base = NULL; + vh1.dirty = false; +strconcat_len(vh1.filename, sizeof(vh1.filename), filename, ".theap", NULL); +if (HEAPload(&vh1, filename, "theap", false) != GDK_SUCCEED) { +GDKfree(srcdir); + HEAPfree(&h1, false); +TRC_CRITICAL(GDK, "loading old string heap " + "for BAT %d failed\n", b->batCacheid); + return GDK_FAIL; +} + + /* create the new heaps */ +Heap *h2 = GDKmalloc(sizeof(Heap)); +Heap *vh2 = GDKmalloc(sizeof(Heap)); +if (h2 == NULL || vh2 == NULL) { + GDKfree(h2); + GDKfree(vh2); + GDKfree(srcdir); + HEAPfree(&h1, false); + HEAPfree(&vh1, false); +TRC_CRITICAL(GDK, "allocating new heaps " + "for BAT %d failed\n", b->batCacheid); + return GDK_FAIL; +} +*h2 = *b->theap; + h2->base = NULL; +if (HEAPalloc(h2, b->batCapacity, b->twidth) != GDK_SUCCEED) { +GDKfree(h2); +GDKfree(vh2); +GDKfree(srcdir); + HEAPfree(&h1, false); + HEAPfree(&vh1, false); + TRC_CRITICAL(GDK, "allocating new tail heap " +"for BAT %d failed\n", b->batCacheid); + return GDK_FAIL; + +} +h2->dirty = true; + h2->free = h1.free; + + *vh2 = *b->tvheap; + strconcat_len(vh2->filename, sizeof(vh2->filename), nme, ".theap", NULL); + strHeap(vh2, b->batCapacity); + if (vh2->base == NULL) { + GDKfree(srcdir); + HEAPfree(&h1, false); + HEAPfree(&vh1, false); + HEAPfree(h2, false); + GDKfree(h2); + GDKfree(vh2); + TRC_CRITICAL(GDK, "allocating new string heap " +"for BAT %d failed\n", b->batCacheid); + return GDK_FAIL; + } +vh2->dirty = true; +ATOMIC_INIT(&h2->refs, 1); +ATOMIC_INIT(&vh2->refs, 1); +Heap *ovh = b->tvheap; +b->tvheap = vh2; + vh2 = NULL; + +for (BUN i = 0; i < b->batCount; i++) { +var_t o = ((var_t *) h1.base)[i]; +const char *s = vh1.base + o; + char *ns; +if (fixJSONStorage(&ns, &s) != GDK_SU
MonetDB: Dec2023 - Fix indentation
Changeset: f4aca4d1583a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f4aca4d1583a Modified Files: gdk/gdk_bbp.c Branch: Dec2023 Log Message: Fix indentation diffs (277 lines): diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -1477,26 +1477,26 @@ movestrbats(void) #ifdef GDKLIBRARY_JSON static gdk_return jsonupgradebat(BAT *b, - json_storage_conversion fixJSONStorage) { +json_storage_conversion fixJSONStorage) { const char *nme = BBP_physical(b->batCacheid); char *srcdir = GDKfilepath(NOFARM, BATDIR, nme, NULL); -if (srcdir == NULL) { + if (srcdir == NULL) { TRC_CRITICAL(GDK, "GDKfilepath failed\n"); return GDK_FAIL; -} + } char *s; if ((s = strrchr(srcdir, DIR_SEP)) != NULL) *s = 0; -const char *bnme; -if ((bnme = strrchr(nme, DIR_SEP)) != NULL) { + const char *bnme; + if ((bnme = strrchr(nme, DIR_SEP)) != NULL) { bnme++; -} else { + } else { bnme = nme; -} - -long_str filename; + } + + long_str filename; snprintf(filename, sizeof(filename), "BACKUP%c%s", DIR_SEP, bnme); /* A json column should not normally have any index structures */ @@ -1509,71 +1509,71 @@ static gdk_return jsonupgradebat(BAT *b, /* bakup the current heaps */ if (GDKmove(b->theap->farmid, srcdir, bnme, "tail", -BAKDIR, bnme, "tail", false) != GDK_SUCCEED) { -GDKfree(srcdir); + BAKDIR, bnme, "tail", false) != GDK_SUCCEED) { + GDKfree(srcdir); TRC_CRITICAL(GDK, "cannot make backup of %s.tail\n", nme); return GDK_FAIL; -} + } GDKclrerr(); -if (GDKmove(b->theap->farmid, srcdir, bnme, "theap", -BAKDIR, bnme, "theap", true) != GDK_SUCCEED) { -GDKfree(srcdir); + if (GDKmove(b->theap->farmid, srcdir, bnme, "theap", + BAKDIR, bnme, "theap", true) != GDK_SUCCEED) { + GDKfree(srcdir); TRC_CRITICAL(GDK, "cannot make backup of %s.theap\n", nme); return GDK_FAIL; -} - - -/* load the old heaps */ -Heap h1 = *b->theap; -h1.base = NULL; -h1.dirty = false; -strconcat_len(h1.filename, sizeof(h1.filename), filename, ".tail", NULL); -if (HEAPload(&h1, filename, "tail", false) != GDK_SUCCEED) { -GDKfree(srcdir); -TRC_CRITICAL(GDK, "loading old tail heap " - "for BAT %d failed\n", b->batCacheid); + } + + + /* load the old heaps */ + Heap h1 = *b->theap; + h1.base = NULL; + h1.dirty = false; + strconcat_len(h1.filename, sizeof(h1.filename), filename, ".tail", NULL); + if (HEAPload(&h1, filename, "tail", false) != GDK_SUCCEED) { + GDKfree(srcdir); + TRC_CRITICAL(GDK, "loading old tail heap " +"for BAT %d failed\n", b->batCacheid); return GDK_FAIL; -} - -Heap vh1 = *b->tvheap; -vh1.base = NULL; + } + + Heap vh1 = *b->tvheap; + vh1.base = NULL; vh1.dirty = false; -strconcat_len(vh1.filename, sizeof(vh1.filename), filename, ".theap", NULL); -if (HEAPload(&vh1, filename, "theap", false) != GDK_SUCCEED) { -GDKfree(srcdir); + strconcat_len(vh1.filename, sizeof(vh1.filename), filename, ".theap", NULL); + if (HEAPload(&vh1, filename, "theap", false) != GDK_SUCCEED) { + GDKfree(srcdir); HEAPfree(&h1, false); -TRC_CRITICAL(GDK, "loading old string heap " - "for BAT %d failed\n", b->batCacheid); + TRC_CRITICAL(GDK, "loading old string heap " +"for BAT %d failed\n", b->batCacheid); return GDK_FAIL; -} + } /* create the new heaps */ -Heap *h2 = GDKmalloc(sizeof(Heap)); -Heap *vh2 = GDKmalloc(sizeof(Heap)); -if (h2 == NULL || vh2 == NULL) { + Heap *h2 = GDKmalloc(sizeof(Heap)); + Heap *vh2 = GDKmalloc(sizeof(Heap)); + if (h2 == NULL || vh2 == NULL) { GDKfree(h2); GDKfree(vh2); GDKfree(srcdir); HEAPfree(&h1, false); HEAPfree(&vh1, false); -TRC_CRITICAL(GDK, "allocating new heaps " - "for BAT %d failed\n", b->batCacheid); + TRC_CRITICAL(GDK, "allocating new heaps " +"for BAT %d failed\n", b->batCacheid); return GDK_FAIL; -} -*h2 = *b->theap; + } +
MonetDB: Jun2023 - Uggly work around to get semaphores working o...
Changeset: e1e5ad7db3af for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e1e5ad7db3af Modified Files: gdk/gdk_system.h Branch: Jun2023 Log Message: Uggly work around to get semaphores working on MacOS with gcc. diffs (26 lines): diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h --- a/gdk/gdk_system.h +++ b/gdk/gdk_system.h @@ -120,6 +120,22 @@ # include #endif +#if defined(__APPLE__) && defined(__GNUC__) +#define HAVE_DISPATCH_DISPATCH_H 1 +#define HAVE_DISPATCH_SEMAPHORE_CREATE 1 +#if __has_attribute(__swift_attr__) +#define OS_SWIFT_UNAVAILABLE_FROM_ASYNC(msg) \ + __attribute__((__swift_attr__("@_unavailableFromAsync(message: \"" msg "\")"))) +#else +#define OS_SWIFT_UNAVAILABLE_FROM_ASYNC(msg) +#endif +#define OS_ASSUME_PTR_ABI_SINGLE_BEGIN __ASSUME_PTR_ABI_SINGLE_BEGIN +#define OS_ASSUME_PTR_ABI_SINGLE_END __ASSUME_PTR_ABI_SINGLE_END +#define OS_UNSAFE_INDEXABLE __unsafe_indexable +#define OS_HEADER_INDEXABLE __header_indexable +#define OS_COUNTED_BY(N) __counted_by(N) +#define OS_SIZED_BY(N) __sized_by(N) +#endif #ifdef HAVE_DISPATCH_DISPATCH_H #include #endif ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org