path: root/builtin.h
diff options
authorMatheus Tavares <>2021-04-19 00:14:54 (GMT)
committerJunio C Hamano <>2021-04-19 18:57:05 (GMT)
commite9e8adf1a871d22d9df7498256681685459b2507 (patch)
treee4d8edcf53f9276566d81d5f07e113e6a2483b1e /builtin.h
parent04155bdad818381681d44448bb7dc3a850117ffb (diff)
parallel-checkout: make it truly parallel
Use multiple worker processes to distribute the queued entries and call write_pc_item() in parallel for them. The items are distributed uniformly in contiguous chunks. This minimizes the chances of two workers writing to the same directory simultaneously, which could affect performance due to lock contention in the kernel. Work stealing (or any other format of re-distribution) is not implemented yet. The protocol between the main process and the workers is quite simple. They exchange binary messages packed in pkt-line format, and use PKT-FLUSH to mark the end of input (from both sides). The main process starts the communication by sending N pkt-lines, each corresponding to an item that needs to be written. These packets contain all the necessary information to load, smudge, and write the blob associated with each item. Then it waits for the worker to send back N pkt-lines containing the results for each item. The resulting packet must contain: the identification number of the item that it refers to, the status of the operation, and the lstat() data gathered after writing the file (iff the operation was successful). For now, checkout always uses a hardcoded value of 2 workers, only to demonstrate that the parallel checkout framework correctly divides and writes the queued entries. The next patch will add user configurations and define a more reasonable default, based on tests with the said settings. Co-authored-by: Nguyễn Thái Ngọc Duy <> Co-authored-by: Jeff Hostetler <> Signed-off-by: Matheus Tavares <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin.h')
1 files changed, 1 insertions, 0 deletions
diff --git a/builtin.h b/builtin.h
index b6ce981..16ecd55 100644
--- a/builtin.h
+++ b/builtin.h
@@ -123,6 +123,7 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix);
int cmd_bundle(int argc, const char **argv, const char *prefix);
int cmd_cat_file(int argc, const char **argv, const char *prefix);
int cmd_checkout(int argc, const char **argv, const char *prefix);
+int cmd_checkout__worker(int argc, const char **argv, const char *prefix);
int cmd_checkout_index(int argc, const char **argv, const char *prefix);
int cmd_check_attr(int argc, const char **argv, const char *prefix);
int cmd_check_ignore(int argc, const char **argv, const char *prefix);