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

[PATCH v2 2/3] fast-export: improve speed by skipping blobs

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 5, 2013, 22:38 UTC
Message-ID
<1367793534-8401-3-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1367793534-8401-1-git-send-email-felipe.contreras@gmail.com>

We don't care about blobs, or any object other than commits, but in order to find the type of object, we are parsing the whole thing, which is slow, specially in big repositories with lots of big files.

There's no need for that, we can query the object information with sha1_object_info();

Before this, loading the objects of a fresh emacs import, with 260598 blobs took 14 minutes, after this patch, it takes 3 seconds.

This is the way fast-import does it. Also die if the object is not found (like fast-import).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin/fast-export.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index a4dee14..a5b8da8 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -613,6 +613,7 @@ static void import_marks(char *input_file)
 		char *line_end, *mark_end;
 		unsigned char sha1[20];
 		struct object *object;
+		enum object_type type;
 
 		line_end = strchr(line, '\n');
 		if (line[0] != ':' || !line_end)
@@ -627,17 +628,19 @@ static void import_marks(char *input_file)
 		if (last_idnum < mark)
 			last_idnum = mark;
 
-		object = parse_object(sha1);
-		if (!object)
+		type = sha1_object_info(sha1, NULL);
+		if (type < 0)
+			die("object not found: %s", sha1_to_hex(sha1));
+
+		if (type != OBJ_COMMIT)
+			/* only commits */
 			continue;
 
+		object = parse_object(sha1);
+
 		if (object->flags & SHOWN)
 			error("Object %s already has a mark", sha1_to_hex(sha1));
 
-		if (object->type != OBJ_COMMIT)
-			/* only commits */
-			continue;
-
 		mark_object(object, mark);
 
 		object->flags |= SHOWN;
-- 
1.8.3.rc0.401.g45bba44
Previous: Junio C HamanoNext: Jeff King
Message 6 of 25 in “fast-export: speed improvements”
  1. 0/3 fast-export: speed improvementsFelipe Contreras, May 5, 2013
  2. 1/3 fast-{import,export}: use get_sha1_hex() directlyFelipe Contreras, May 5, 2013
  3. Junio C HamanoMay 7, 2013
  4. Felipe ContrerasMay 7, 2013
  5. Junio C HamanoMay 7, 2013
  6. 2/3 fast-export: improve speed by skipping blobsFelipe Contreras, May 5, 2013
  7. Jeff KingMay 6, 2013
  8. Junio C HamanoMay 6, 2013
  9. Junio C HamanoMay 6, 2013
  10. Jeff KingMay 6, 2013
  11. Junio C HamanoMay 6, 2013
  12. Jeff KingMay 6, 2013
  13. Junio C HamanoMay 6, 2013
  14. Jeff KingMay 6, 2013
  15. Jeff KingMay 6, 2013
  16. Felipe ContrerasMay 6, 2013
  17. Felipe ContrerasMay 6, 2013
  18. Junio C HamanoMay 6, 2013
  19. Felipe ContrerasMay 6, 2013
  20. Junio C HamanoMay 7, 2013
  21. Felipe ContrerasMay 7, 2013
  22. Felipe ContrerasMay 6, 2013
  23. Jeff KingMay 6, 2013
  24. Felipe ContrerasMay 6, 2013
  25. 3/3 fast-export: don't parse all the commitsFelipe Contreras, May 5, 2013

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.