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

Re: [PATCH 3/5] parallel-checkout: add configuration options

From
Christian Couder <christian.couder@gmail.com>
Date
Mar 31, 2021, 04:33 UTC
Message-ID
<CAP8UFD3s3NUpi2eyPWFa5bL4rez1wNtj5-dUpv8dJLo2CKYu9A@mail.gmail.com>
In-Reply-To
<8c83e92445b4131e9b8f8e2aa29b00717b257d13.1616015337.git.matheus.bernardino@usp.br>

On Wed, Mar 17, 2021 at 10:12 PM Matheus Tavares <matheus.bernardino@usp.br> wrote:

Show 6 quoted lines
> The above benchmarks show that parallel checkout is most effective on
> repositories located on an SSD or over a distributed file system. For
> local file systems on spinning disks, and/or older machines, the
> parallelism does not always bring a good performance. For this reason,
> the default value for checkout.workers is one, a.k.a. sequential
> checkout.

I wonder how many people are still using HDD, and how many will still use them in a few years.

I think having 1 as the default value for checkout.workers might be good for a while for backward compatibility and stability, while people who are interested can test parallel checkout on different environments. But we might want, in a few releases, after some bugs, if any, have been fixed, to use a default, maybe 10, that will provide significant speedup for most people, and will justify the added complexity, especially as your numbers still show a small speedup for HDD when using 10.

Show 6 quoted lines
> To decide the default value for checkout.thresholdForParallelism,
> another benchmark was executed in the "Local SSD" setup, where parallel
> checkout showed to be beneficial. This time, we compared the runtime of
> a `git checkout -f`, with and without parallelism, after randomly
> removing an increasing number of files from the Linux working tree. The
> "sequential fallback" column bellow corresponds to the executions where
s/bellow/below/
Show 33 quoted lines
> checkout.workers was 10 but checkout.thresholdForParallelism was equal
> to the number of to-be-updated files plus one (so that we end up writing
> sequentially). Each test case was sampled 15 times, and each sample had
> a randomly different set of files removed. Here are the results:
>
>              sequential fallback   10 workers           speedup
> 10   files    772.3 ms ± 12.6 ms   769.0 ms ± 13.6 ms   1.00 ± 0.02
> 20   files    780.5 ms ± 15.8 ms   775.2 ms ±  9.2 ms   1.01 ± 0.02
> 50   files    806.2 ms ± 13.8 ms   767.4 ms ±  8.5 ms   1.05 ± 0.02
> 100  files    833.7 ms ± 21.4 ms   750.5 ms ± 16.8 ms   1.11 ± 0.04
> 200  files    897.6 ms ± 30.9 ms   730.5 ms ± 14.7 ms   1.23 ± 0.05
> 500  files   1035.4 ms ± 48.0 ms   677.1 ms ± 22.3 ms   1.53 ± 0.09
> 1000 files   1244.6 ms ± 35.6 ms   654.0 ms ± 38.3 ms   1.90 ± 0.12
> 2000 files   1488.8 ms ± 53.4 ms   658.8 ms ± 23.8 ms   2.26 ± 0.12
>
> From the above numbers, 100 files seems to be a reasonable default value
> for the threshold setting.
>
> Note: Up to 1000 files, we observe a drop in the execution time of the
> parallel code with an increase in the number of files. This is a rather
> odd behavior, but it was observed in multiple repetitions. Above 1000
> files, the execution time increases according to the number of files, as
> one would expect.
>
> About the test environments: Local SSD tests were executed on an
> i7-7700HQ (4 cores with hyper-threading) running Manjaro Linux. Local
> HDD tests were executed on an Intel(R) Xeon(R) E3-1230 (also 4 cores
> with hyper-threading), HDD Seagate Barracuda 7200.14 SATA 3.1, running
> Debian. NFS and EFS tests were executed on an Amazon EC2 c5n.xlarge
> instance, with 4 vCPUs. The Linux NFS server was running on a m6g.large
> instance with 2 vCPUSs and a 1 TB EBS GP2 volume. Before each timing,
> the linux repository was removed (or checked out back to its previous
> state), and `sync && sysctl vm.drop_caches=3` was executed.
Thanks for all these tests and details!
> Co-authored-by: Jeff Hostetler <jeffhost@microsoft.com>
> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
[...]
Show 5 quoted lines
> @@ -23,6 +25,19 @@ enum pc_status parallel_checkout_status(void)
>         return parallel_checkout.status;
>  }
>
> +#define DEFAULT_THRESHOLD_FOR_PARALLELISM 100
Using a "static const int" might be a bit better.
> +void get_parallel_checkout_configs(int *num_workers, int *threshold)
> +{
> +       if (git_config_get_int("checkout.workers", num_workers))
> +               *num_workers = 1;

I think it's better when an important default value like this "1" is made more visible using a "static const int" or a "#define".

Show 15 quoted lines
> +       else if (*num_workers < 1)
> +               *num_workers = online_cpus();
> +
> +       if (git_config_get_int("checkout.thresholdForParallelism", threshold))
> +               *threshold = DEFAULT_THRESHOLD_FOR_PARALLELISM;
> +}
> +
>  void init_parallel_checkout(void)
>  {
>         if (parallel_checkout.status != PC_UNINITIALIZED)
> @@ -554,11 +569,9 @@ static void write_items_sequentially(struct checkout *state)
>                 write_pc_item(&parallel_checkout.items[i], state);
>  }
>
> -#define DEFAULT_NUM_WORKERS 2
As I say above, it doesn't look like a good idea to have removed this.
Show 14 quoted lines
> -int run_parallel_checkout(struct checkout *state)
> +int run_parallel_checkout(struct checkout *state, int num_workers, int threshold)
>  {
> -       int ret, num_workers = DEFAULT_NUM_WORKERS;
> +       int ret;
>
>         if (parallel_checkout.status != PC_ACCEPTING_ENTRIES)
>                 BUG("cannot run parallel checkout: uninitialized or already running");
> @@ -568,7 +581,7 @@ int run_parallel_checkout(struct checkout *state)
>         if (parallel_checkout.nr < num_workers)
>                 num_workers = parallel_checkout.nr;
>
> -       if (num_workers <= 1) {
> +       if (num_workers <= 1 || parallel_checkout.nr < threshold) {
Here we check the number of workers...
>                 write_items_sequentially(state);
>         } else {
>                 struct pc_worker *workers = setup_workers(state, num_workers);
[...]
Show 6 quoted lines
> @@ -480,7 +483,8 @@ static int check_updates(struct unpack_trees_options *o,
>                 }
>         }
>         stop_progress(&progress);
> -       errs |= run_parallel_checkout(&state);
> +       if (pc_workers > 1)
...but the number of workers was already checked here.
> +               errs |= run_parallel_checkout(&state, pc_workers, pc_threshold);
>         errs |= finish_delayed_checkout(&state, NULL);
>         git_attr_set_direction(GIT_ATTR_CHECKIN);
Previous: Matheus TavaresNext: Matheus Tavares Bernardino
Message 6 of 40 in “Parallel Checkout (part 2)”
  1. 0/5 Parallel Checkout (part 2)Matheus Tavares, Mar 17, 2021
  2. 1/5 unpack-trees: add basic support for parallel checkoutMatheus Tavares, Mar 17, 2021
  3. Christian CouderMar 31, 2021
  4. Matheus Tavares BernardinoApr 2, 2021
  5. 3/5 parallel-checkout: add configuration optionsMatheus Tavares, Mar 17, 2021
  6. Christian CouderMar 31, 2021
  7. Matheus Tavares BernardinoApr 2, 2021
  8. 5/5 parallel-checkout: add design documentationMatheus Tavares, Mar 17, 2021
  9. Christian CouderMar 31, 2021
  10. 4/5 parallel-checkout: support progress displayingMatheus Tavares, Mar 17, 2021
  11. 2/5 parallel-checkout: make it truly parallelMatheus Tavares, Mar 17, 2021
  12. Christian CouderMar 31, 2021
  13. Matheus Tavares BernardinoApr 2, 2021
  14. Junio C HamanoMar 18, 2021
  15. Matheus TavaresMar 19, 2021
  16. Junio C HamanoMar 19, 2021
  17. Christian CouderMar 31, 2021
  18. 0/5 Parallel Checkout (part 2)Matheus Tavares, Apr 8, 2021
  19. 1/5 unpack-trees: add basic support for parallel checkoutMatheus Tavares, Apr 8, 2021
  20. 2/5 parallel-checkout: make it truly parallelMatheus Tavares, Apr 8, 2021
  21. 3/5 parallel-checkout: add configuration optionsMatheus Tavares, Apr 8, 2021
  22. 4/5 parallel-checkout: support progress displayingMatheus Tavares, Apr 8, 2021
  23. 5/5 parallel-checkout: add design documentationMatheus Tavares, Apr 8, 2021
  24. Junio C HamanoApr 8, 2021
  25. Junio C HamanoApr 16, 2021
  26. Matheus Tavares BernardinoApr 17, 2021
  27. Christian CouderApr 19, 2021
  28. 0/5 Parallel Checkout (part 2)Matheus Tavares, Apr 19, 2021
  29. 1/5 unpack-trees: add basic support for parallel checkoutMatheus Tavares, Apr 19, 2021
  30. 2/5 parallel-checkout: make it truly parallelMatheus Tavares, Apr 19, 2021
  31. 3/5 parallel-checkout: add configuration optionsMatheus Tavares, Apr 19, 2021
  32. 4/5 parallel-checkout: support progress displayingMatheus Tavares, Apr 19, 2021
  33. 5/5 parallel-checkout: add design documentationMatheus Tavares, Apr 19, 2021
  34. Christian CouderApr 19, 2021
  35. 0/5 Parallel Checkout (part 2)Matheus Tavares, Apr 19, 2021
  36. 1/5 unpack-trees: add basic support for parallel checkoutMatheus Tavares, Apr 19, 2021
  37. 2/5 parallel-checkout: make it truly parallelMatheus Tavares, Apr 19, 2021
  38. 3/5 parallel-checkout: add configuration optionsMatheus Tavares, Apr 19, 2021
  39. 4/5 parallel-checkout: support progress displayingMatheus Tavares, Apr 19, 2021
  40. 5/5 parallel-checkout: add design documentationMatheus Tavares, Apr 19, 2021

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.