Changeset: b3eabb44921c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b3eabb44921c
Modified Files:
        gdk/ChangeLog.Sep2022
        gdk/gdk_heap.c
Branch: Sep2022
Log Message:

Merge with Jan2022 branch.


diffs (52 lines):

diff --git a/gdk/ChangeLog.Sep2022 b/gdk/ChangeLog.Sep2022
--- a/gdk/ChangeLog.Sep2022
+++ b/gdk/ChangeLog.Sep2022
@@ -1,3 +1,9 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Mon Oct 10 2022 Sjoerd Mullender <[email protected]>
+- Offset heaps (.tailN files) were growing too fast and unnecessarily
+  under certain conditions.  This has been fixed.  Also, when such too
+  large files are now loaded into the system, it is recognized they are
+  too large and they are truncated to a more reasonable size.
+
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -674,21 +674,23 @@ HEAPload_intern(Heap *h, const char *nme
        if (trunc) {
                /* round up mmap heap sizes to GDK_mmap_pagesize
                 * segments, also add some slack */
-               size_t truncsize = ((size_t) (h->free * 1.05) + 
GDK_mmap_pagesize - 1) & ~(GDK_mmap_pagesize - 1);
                int fd;
 
-               if (truncsize == 0)
-                       truncsize = GDK_mmap_pagesize; /* minimum of one page */
-               if (truncsize < h->size &&
-                   (fd = GDKfdlocate(h->farmid, nme, "mrb+", ext)) >= 0) {
-                       ret = ftruncate(fd, truncsize);
-                       TRC_DEBUG(HEAP,
-                                 "ftruncate(file=%s.%s, size=%zu) = %d\n",
-                                 nme, ext, truncsize, ret);
+               if (minsize == 0)
+                       minsize = GDK_mmap_pagesize; /* minimum of one page */
+               if ((fd = GDKfdlocate(h->farmid, nme, "rb+", ext)) >= 0) {
+                       struct stat stb;
+                       if (fstat(fd, &stb) == 0 &&
+                           stb.st_size > (off_t) minsize) {
+                               ret = ftruncate(fd, minsize);
+                               TRC_DEBUG(HEAP,
+                                         "ftruncate(file=%s.%s, size=%zu) = 
%d\n",
+                                         nme, ext, minsize, ret);
+                               if (ret == 0) {
+                                       h->size = minsize;
+                               }
+                       }
                        close(fd);
-                       if (ret == 0) {
-                               h->size = truncsize;
-                       }
                }
        }
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to