Changeset: 97ad06a53785 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=97ad06a53785
Modified Files:
        gdk/gdk_heap.c
Branch: Oct2014
Log Message:

Updated some comments.


diffs (84 lines):

diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -153,25 +153,24 @@ HEAPalloc(Heap *h, size_t nitems, size_t
        return 0;
 }
 
-/*
- * @- HEAPextend
+/* Extend the allocated space of the heap H to be at least SIZE bytes.
+ * If the heap grows beyond a threshold and a filename is known, the
+ * heap is converted from allocated memory to a memory-mapped file.
+ * When switching from allocated to memory mapped, if MAYSHARE is set,
+ * the heap does not have to be copy-on-write.
  *
- * Normally (last case in the below code), we use GDKrealloc, except
- * for the case that the heap extends to a huge size, in which case we
- * open memory mapped file.
+ * The function returns 0 on success, -1 on failure.
  *
- * Observe that we may assume that the BAT is writable here
- * (otherwise, why extend?).
+ * When extending a memory-mapped heap, we use the function MT_mremap
+ * (which see).  When extending an allocated heap, we use GDKrealloc.
+ * If that fails, we switch to memory mapped, even when the size is
+ * below the threshold.
  *
- * For memory mapped files, we may try to extend the file after the
- * end, and also extend the VM space we already have. This may fail,
- * e.g. due to VM fragmentation or no swap space (we map the new
- * segment STORE_PRIV). Also, some OS-es might not support this at all
- * (NOEXTEND_PRIVMAP).
- *
- * The other way is to just save the mmap-ed heap, free it and reload
- * it.
- */
+ * When converting from allocated to memory mapped, we try several
+ * strategies.  First we try to create the memory map, and if that
+ * works, copy the data and free the old memory.  If this fails, we
+ * first write the data to disk, free the memory, and then try to
+ * memory map the saved data. */
 int
 HEAPextend(Heap *h, size_t size, int mayshare)
 {
@@ -558,11 +557,8 @@ HEAPcopy(Heap *dst, Heap *src)
        return -1;
 }
 
-/*
- * @- HEAPfree
- * Is now called even on heaps without memory, just to free the
- * pre-allocated filename.  simple: alloc and copy.
- */
+/* Free the memory associated with the heap H.
+ * Does not destroy any files associated with the heap. */
 int
 HEAPfree(Heap *h)
 {
@@ -765,10 +761,7 @@ HEAPwarm(Heap *h)
 }
 
 
-/*
- * @- HEAPvmsize
- * count all memory that takes up address space.
- */
+/* Return the (virtual) size of the heap. */
 size_t
 HEAPvmsize(Heap *h)
 {
@@ -777,11 +770,8 @@ HEAPvmsize(Heap *h)
        return 0;
 }
 
-/*
- * @- HEAPmemsize
- * count all memory that takes up swap space. We conservatively count
- * STORE_PRIV heaps as fully backed by swap space.
- */
+/* Return the allocated size of the heap, i.e. if the heap is memory
+ * mapped and not copy-on-write (privately mapped), return 0. */
 size_t
 HEAPmemsize(Heap *h)
 {
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to