git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: git@vger.kernel.org
Subject: [PATCH] delta-islands: free island_marks and bitmaps
Date: Thu,  2 Feb 2023 01:03:53 +0000	[thread overview]
Message-ID: <20230202010353.23391-1-e@80x24.org> (raw)

On my mirror of linux.git forkgroup with 780 islands, this saves
nearly 4G of heap memory in pack-objects.  This savings only
benefits delta island users of pack bitmaps, as the process
would otherwise be exiting anyways.

However, there's probably not many delta island users, but the
majority of delta island users would also be pack bitmaps users.

Signed-off-by: Eric Wong <e@80x24.org>
---
 Slowly chipping away, this is low-hanging fruit.

 delta-islands.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/delta-islands.c b/delta-islands.c
index 90c0d6958f..7052a3a6ba 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -513,12 +513,29 @@ void propagate_island_marks(struct commit *commit)
 	}
 }
 
+static void free_island_marks(void)
+{
+	struct island_bitmap *bitmap;
+
+	kh_foreach_value(island_marks, bitmap, {
+		if (--bitmap->refcount == 0)
+			free(bitmap);
+	});
+	kh_destroy_oid_map(island_marks);
+	island_marks = (void *)1; /* crash on unintended future use */
+}
+
 int compute_pack_layers(struct packing_data *to_pack)
 {
 	uint32_t i;
 
-	if (!core_island_name || !island_marks)
+	if (!island_marks)
+		return 1;
+
+	if (!core_island_name) {
+		free_island_marks();
 		return 1;
+	}
 
 	for (i = 0; i < to_pack->nr_objects; ++i) {
 		struct object_entry *entry = &to_pack->objects[i];
@@ -533,6 +550,7 @@ int compute_pack_layers(struct packing_data *to_pack)
 				oe_set_layer(to_pack, entry, 0);
 		}
 	}
+	free_island_marks();
 
 	return 2;
 }

             reply	other threads:[~2023-02-02  1:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02  1:03 Eric Wong [this message]
2023-02-02  1:45 ` [PATCH] delta-islands: free island_marks and bitmaps Ævar Arnfjörð Bjarmason
2023-02-02  9:42   ` [PATCH v2] " Eric Wong
2023-02-03 18:11     ` Jeff King
2023-02-03 23:44       ` [PATCH v3] " Eric Wong
2023-02-04 11:14         ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230202010353.23391-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).