Skip to contentSkip to conversation

fast-import: treat SIGUSR1 as a request to access objects early

PATCH/RFC Jonathan Nieder 2 participants 3 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

It can be tedious to wait for a multi-million-revision import. Unfortunately it is hard to spy on the import because fast-import works by continuously streaming out objects, without updating the pack index or refs until a checkpoint command or the end of the stream.

So allow the impatient operator to request checkpoints by sending a signal, like so:

killall -USR1 git-fast-import

When receiving such a signal, fast-import would schedule a checkpoint to take place after the current top-level command (usually a "commit" or "blob" request) finishes.

Caveats: just like ordinary checkpoint commands, such requests slow down the import. Switching to a new pack at a suboptimal moment is also likely to result in a less dense initial collection of packs. That's the price.

---
Thoughts?

 Documentation/git-fast-import.txt |    8 +++++++
 fast-import.c                     |   42 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 1 deletions(-)
Documentation/git-fast-import.txt +8 -0
index 5d0c245..526670a 100644
@@ -1233,6 +1233,14 @@ and lazy loading of subtrees, allows fast-import to efficiently import
 projects with 2,000+ branches and 45,114+ files in a very limited
 memory footprint (less than 2.7 MiB per active branch).
 
+Signals
+-------
+Sending *SIGUSR1* to the 'git fast-import' process ends the current
+packfile early, simulating a `checkpoint` command.  The impatient
+operator can use this facility to peek at the objects and refs from an
+import in progress, at the cost of some added running time and worse
+compression.
+
 
 Author
 ------
fast-import.c +41 -1

79 lines not on this page · raw message

Signature · 1 line
1.7.2.3
#1 lore raw

fast-import.c static void parse_reset_branch(void) · line 2737

Quoted 5 lines · Jonathan Nieder
fast-import.c +3 -0
+static void parse_checkpoint(void)
+{
+	do_checkpoint();
 	skip_optional_lf();
 }

I would have expected the new implementation of parse_checkpoint() to just set the checkpoint_requested variable to true, so that the checkpoint always happens in the main loop, which somehow feels cleaner. But that is a minor point.

#2 lore raw
Quoted 3 lines · Junio C Hamano

I would have expected the new implementation of parse_checkpoint() to just set the checkpoint_requested variable to true, so that the checkpoint always happens in the main loop, which somehow feels cleaner.

Nice. Here's that plus some minor cleanups I had in my tree.

---

Documentation/git-fast-import.txt +0 -1
index 6be3938..5937cc0 100644
@@ -1119,7 +1119,6 @@ operator can use this facility to peek at the objects and refs from an
 import in progress, at the cost of some added running time and worse
 compression.
 
-
 Author
 ------
 Written by Shawn O. Pearce <[email protected]>.
fast-import.c +3 -4
index e8f08fb..a348994 100644
@@ -490,7 +490,6 @@ static NORETURN void die_nicely(const char *err, va_list params)
 
 static void set_checkpoint_signal(void)
 {
-	/* nothing */
 }
 
 #else
@@ -2351,7 +2350,7 @@ static void parse_reset_branch(void)
 		unread_command_buf = 1;
 }
 
-static void do_checkpoint(void)
+static void checkpoint(void)
 {
 	checkpoint_requested = 0;
 	if (object_count) {
@@ -2364,7 +2363,7 @@ static void do_checkpoint(void)
 
 static void parse_checkpoint(void)
 {
-	do_checkpoint();
+	checkpoint_requested = 1;
 	skip_optional_lf();
 }
 
@@ -2524,7 +2523,7 @@ int main(int argc, const char **argv)
 			die("Unsupported command: %s", command_buf.buf);
 
 		if (checkpoint_requested)
-			do_checkpoint();
+			checkpoint();
 	}
 	end_packfile();