summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-04-30 04:50:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-04-30 04:50:26 (GMT)
commita1cac26cc60f611b2f94badfc9c8522a65e79dc1 (patch)
tree5bbbdc78161815ae9a3b68e3cb0469dbefbc998a /unpack-trees.c
parent59bb0aa93e6edaca44b2a5488fc915d468bae46f (diff)
parent68e66f2987724a639c896e7996ea347be62ef578 (diff)
downloadgit-a1cac26cc60f611b2f94badfc9c8522a65e79dc1.zip
git-a1cac26cc60f611b2f94badfc9c8522a65e79dc1.tar.gz
git-a1cac26cc60f611b2f94badfc9c8522a65e79dc1.tar.bz2
Merge branch 'mt/parallel-checkout-part-2'
The checkout machinery has been taught to perform the actual write-out of the files in parallel when able. * mt/parallel-checkout-part-2: parallel-checkout: add design documentation parallel-checkout: support progress displaying parallel-checkout: add configuration options parallel-checkout: make it truly parallel unpack-trees: add basic support for parallel checkout
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index 9cffa88..7a1804c 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -17,6 +17,7 @@
#include "object-store.h"
#include "promisor-remote.h"
#include "entry.h"
+#include "parallel-checkout.h"
/*
* Error messages expected by scripts out of plumbing commands such as
@@ -398,7 +399,7 @@ static int check_updates(struct unpack_trees_options *o,
int errs = 0;
struct progress *progress;
struct checkout state = CHECKOUT_INIT;
- int i;
+ int i, pc_workers, pc_threshold;
trace_performance_enter();
state.force = 1;
@@ -441,7 +442,6 @@ static int check_updates(struct unpack_trees_options *o,
if (should_update_submodules())
load_gitmodules_file(index, &state);
- enable_delayed_checkout(&state);
if (has_promisor_remote()) {
/*
* Prefetch the objects that are to be checked out in the loop
@@ -464,18 +464,31 @@ static int check_updates(struct unpack_trees_options *o,
to_fetch.oid, to_fetch.nr);
oid_array_clear(&to_fetch);
}
+
+ get_parallel_checkout_configs(&pc_workers, &pc_threshold);
+
+ enable_delayed_checkout(&state);
+ if (pc_workers > 1)
+ init_parallel_checkout();
for (i = 0; i < index->cache_nr; i++) {
struct cache_entry *ce = index->cache[i];
if (ce->ce_flags & CE_UPDATE) {
+ size_t last_pc_queue_size = pc_queue_size();
+
if (ce->ce_flags & CE_WT_REMOVE)
BUG("both update and delete flags are set on %s",
ce->name);
- display_progress(progress, ++cnt);
ce->ce_flags &= ~CE_UPDATE;
errs |= checkout_entry(ce, &state, NULL, NULL);
+
+ if (last_pc_queue_size == pc_queue_size())
+ display_progress(progress, ++cnt);
}
}
+ if (pc_workers > 1)
+ errs |= run_parallel_checkout(&state, pc_workers, pc_threshold,
+ progress, &cnt);
stop_progress(&progress);
errs |= finish_delayed_checkout(&state, NULL);
git_attr_set_direction(GIT_ATTR_CHECKIN);