Changeset: d6c70479d748 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d6c70479d748
Modified Files:
        gdk/gdk_system.c
        gdk/gdk_system_private.h
        gdk/gdk_utils.c
        sql/storage/store.c
Branch: Nov2019
Log Message:

Implemented a slightly hacky way to ignore soft limit during transaction 
processing.


diffs (107 lines):

diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -277,6 +277,14 @@ MT_thread_setworking(const char *work)
                w->working = work;
 }
 
+bool
+MT_thread_override_limits(void)
+{
+       struct winthread *w = TlsGetValue(threadslot);
+
+       return w && w->working && strcmp(w->working, "store locked") == 0;
+}
+
 void *
 MT_thread_getdata(void)
 {
@@ -598,6 +606,14 @@ MT_thread_setworking(const char *work)
                p->working = work;
 }
 
+bool
+MT_thread_override_limits(void)
+{
+       struct posthread *p = pthread_getspecific(threadkey);
+
+       return p && p->working && strcmp(p->working, "store locked") == 0;
+}
+
 #ifdef HAVE_PTHREAD_SIGMASK
 static void
 MT_thread_sigmask(sigset_t *new_mask, sigset_t *orig_mask)
diff --git a/gdk/gdk_system_private.h b/gdk/gdk_system_private.h
--- a/gdk/gdk_system_private.h
+++ b/gdk/gdk_system_private.h
@@ -18,3 +18,5 @@
        __attribute__((__visibility__("hidden")));
 __hidden int MT_kill_thread(MT_Id t)
        __attribute__((__visibility__("hidden")));
+__hidden bool MT_thread_override_limits(void)
+       __attribute__((__visibility__("hidden")));
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1824,7 +1824,8 @@ GDKmalloc_internal(size_t size)
                return NULL;
        }
 #endif
-       if (GDKvm_cursize() + size >= GDK_vm_maxsize) {
+       if (GDKvm_cursize() + size >= GDK_vm_maxsize &&
+           !MT_thread_override_limits()) {
                GDKerror("allocating too much memory\n");
                return NULL;
        }
@@ -1967,7 +1968,8 @@ GDKrealloc(void *s, size_t size)
        asize = ((size_t *) s)[-1]; /* how much allocated last */
 
        if (nsize > asize &&
-           GDKvm_cursize() + nsize - asize >= GDK_vm_maxsize) {
+           GDKvm_cursize() + nsize - asize >= GDK_vm_maxsize &&
+           !MT_thread_override_limits()) {
                GDKerror("allocating too much memory\n");
                return NULL;
        }
@@ -2097,7 +2099,8 @@ GDKmmap(const char *path, int mode, size
 {
        void *ret;
 
-       if (GDKvm_cursize() + len >= GDK_vm_maxsize) {
+       if (GDKvm_cursize() + len >= GDK_vm_maxsize &&
+           !MT_thread_override_limits()) {
                GDKmemfail("GDKmmap", len);
                GDKerror("allocating too much virtual address space\n");
                return NULL;
@@ -2131,7 +2134,8 @@ GDKmremap(const char *path, int mode, vo
        void *ret;
 
        if (*new_size > old_size &&
-           GDKvm_cursize() + *new_size - old_size >= GDK_vm_maxsize) {
+           GDKvm_cursize() + *new_size - old_size >= GDK_vm_maxsize &&
+           !MT_thread_override_limits()) {
                GDKmemfail("GDKmmap", *new_size);
                GDKerror("allocating too much virtual address space\n");
                return NULL;
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -2334,6 +2334,9 @@ void
 store_lock(void)
 {
        MT_lock_set(&bs_lock);
+       /* tell GDK allocation functions to ignore limits */
+       MT_thread_setworking("store locked");
+
 #ifdef STORE_DEBUG
        fprintf(stderr, "#locked\n");
 #endif
@@ -2345,6 +2348,8 @@ store_unlock(void)
 #ifdef STORE_DEBUG
        fprintf(stderr, "#unlocked\n");
 #endif
+       /* tell GDK allocation functions to honor limits again */
+       MT_thread_setworking("store unlocked");
        MT_lock_unset(&bs_lock);
 }
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to