git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] pack-objects: only throw away data during memory pressure

From
MKMartin Koegler <mkoegler@auto.tuwien.ac.at>
Date
Feb 11, 2008, 07:26 UTC
Message-ID
<120271478556-git-send-email-mkoegler@auto.tuwien.ac.at>

If pack-objects hit the memory limit, it deletes objects from the delta window.

This patch make it only delete the data, which is recomputed, if needed again.
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
What about this not really tested patch for dealing with memory pressure in git-pack-objects?
It will slow down the repack in the case of memory pressure, but missing memory will not affect the results.
 builtin-pack-objects.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 6f8f388..231d65f 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1464,7 +1464,7 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)
 	return m;
 }
 
-static unsigned long free_unpacked(struct unpacked *n)
+static unsigned long free_unpacked_data(struct unpacked *n)
 {
 	unsigned long freed_mem = sizeof_delta_index(n->index);
 	free_delta_index(n->index);
@@ -1474,6 +1474,12 @@ static unsigned long free_unpacked(struct unpacked *n)
 		free(n->data);
 		n->data = NULL;
 	}
+	return freed_mem;
+}
+
+static unsigned long free_unpacked(struct unpacked *n)
+{
+	unsigned long freed_mem = free_unpacked_data(n);
 	n->entry = NULL;
 	n->depth = 0;
 	return freed_mem;
@@ -1514,7 +1520,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
 		       mem_usage > window_memory_limit &&
 		       count > 1) {
 			uint32_t tail = (idx + window - count) % window;
-			mem_usage -= free_unpacked(array + tail);
+			mem_usage -= free_unpacked_data(array + tail);
 			count--;
 		}
 
@@ -1547,6 +1553,9 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
 			if (!m->entry)
 				break;
 			ret = try_delta(n, m, max_depth, &mem_usage);
+			if (window_memory_limit &&
+			    mem_usage > window_memory_limit)
+				mem_usage -= free_unpacked_data(m);
 			if (ret < 0)
 				break;
 			else if (ret > 0)
-- 
1.5.4.g42f90
Next: Johannes Schindelin
Message 1 of 12 in “pack-objects: only throw away data during memory pressure”
  1. pack-objects: only throw away data during memory pressureMartin Koegler, Feb 11, 2008
  2. Johannes SchindelinFeb 11, 2008
  3. Nicolas PitreFeb 11, 2008
  4. Johannes SchindelinFeb 11, 2008
  5. Nicolas PitreFeb 11, 2008
  6. Brian DowningFeb 12, 2008
  7. Nicolas PitreFeb 12, 2008
  8. Brian DowningFeb 12, 2008
  9. Brian DowningFeb 12, 2008
  10. Brian DowningFeb 12, 2008
  11. Nicolas PitreFeb 12, 2008
  12. Nicolas PitreFeb 13, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.