Thread (183 messages) 183 messages, 9 authors, 2022-06-11

Re: [RFC PATCH] object-file.c: batched disk flushes for stream_loose_object()

From: Neeraj Singh <hidden>
Date: 2022-06-09 07:35:16

On 6/8/2022 8:05 PM, Han Xin wrote:
quoted hunk ↗ jump to hunk
Neeraj Singh[1] pointed out that if batch fsync is enabled, we should still
call prepare_loose_object_bulk_checkin() to potentially create the bulk checkin
objdir.

1. https://lore.kernel.org/git/7ba4858a-d1cc-a4eb-b6d6-4c04a5dd6ce7@gmail.com/ (local)

Signed-off-by: Han Xin <redacted>
---
  object-file.c                   |  3 +++
  t/t5351-unpack-large-objects.sh | 15 ++++++++++++++-
  2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/object-file.c b/object-file.c
index 2dd828b45b..3a1be74775 100644
--- a/object-file.c
+++ b/object-file.c
@@ -2131,6 +2131,9 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,
  	char hdr[MAX_HEADER_LEN];
  	int hdrlen;
  
+	if (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))
+		prepare_loose_object_bulk_checkin();
+
  	/* Since oid is not determined, save tmp file to odb path. */
  	strbuf_addf(&filename, "%s/", get_object_directory());
  	hdrlen = format_object_header(hdr, sizeof(hdr), OBJ_BLOB, len);
diff --git a/t/t5351-unpack-large-objects.sh b/t/t5351-unpack-large-objects.sh
index 461ca060b2..a66a51f7df 100755
--- a/t/t5351-unpack-large-objects.sh
+++ b/t/t5351-unpack-large-objects.sh
@@ -18,7 +18,10 @@ test_expect_success "create large objects (1.5 MB) and PACK" '
  	test_commit --append foo big-blob &&
  	test-tool genrandom bar 1500000 >big-blob &&
  	test_commit --append bar big-blob &&
-	PACK=$(echo HEAD | git pack-objects --revs pack)
+	PACK=$(echo HEAD | git pack-objects --revs pack) &&
+	git verify-pack -v pack-$PACK.pack |
+	    grep -E "commit|tree|blob" |
+		sed -n -e "s/^\([0-9a-f]*\).*/\1/p" >obj-list
  '
  
  test_expect_success 'set memory limitation to 1MB' '
@@ -45,6 +48,16 @@ test_expect_success 'unpack big object in stream' '
  	test_dir_is_empty dest.git/objects/pack
  '
  
+BATCH_CONFIGURATION='-c core.fsync=loose-object -c core.fsyncmethod=batch'
+
+test_expect_success 'unpack big object in stream (core.fsyncmethod=batch)' '
+	prepare_dest 1m &&
+	git $BATCH_CONFIGURATION -C dest.git unpack-objects <pack-$PACK.pack &&
+	test_dir_is_empty dest.git/objects/pack &&
+	git -C dest.git cat-file --batch-check="%(objectname)" <obj-list >current &&
+	cmp obj-list current
+'
+
  test_expect_success 'do not unpack existing large objects' '
  	prepare_dest 1m &&
  	git -C dest.git index-pack --stdin <pack-$PACK.pack &&
This fix looks good to me.

Thanks.

-Neeraj
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help