Allow pack.threads config option and --threads command line option to
accept '0' as an argument and set the number of created threads equal
to the number of online processors in this case.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
I was preparing this patch when I saw your email. I looked up your
the old email you were talking about. Your function is better since
it is cross platform.
When you redo your patch, you may want to adopt one aspect of this
one. I used a setting of zero to imply "set number of threads to
number of cpus". This allows the user to specifically set pack.threads
in the config file to zero with the above mentioned meaning, or to
override a setting in the config file from the command line with
--threads=0. This is rather than having to delete the option from the
config file.
-brandon
builtin-pack-objects.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 692a761..5c55c11 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1852,11 +1852,11 @@ static int git_pack_config(const char *k, const char *v)
}
if (!strcmp(k, "pack.threads")) {
delta_search_threads = git_config_int(k, v);
- if (delta_search_threads < 1)
+ if (delta_search_threads < 0)
die("invalid number of threads specified (%d)",
delta_search_threads);
#ifndef THREADED_DELTA_SEARCH
- if (delta_search_threads > 1)
+ if (delta_search_threads != 1)
warning("no threads support, ignoring %s", k);
#endif
return 0;
@@ -2121,10 +2121,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
if (!prefixcmp(arg, "--threads=")) {
char *end;
delta_search_threads = strtoul(arg+10, &end, 0);
- if (!arg[10] || *end || delta_search_threads < 1)
+ if (!arg[10] || *end || delta_search_threads < 0)
usage(pack_usage);
#ifndef THREADED_DELTA_SEARCH
- if (delta_search_threads > 1)
+ if (delta_search_threads != 1)
warning("no threads support, "
"ignoring %s", arg);
#endif
@@ -2234,6 +2234,20 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
if (!pack_to_stdout && thin)
die("--thin cannot be used to build an indexable pack.");
+#ifdef THREADED_DELTA_SEARCH
+ if (!delta_search_threads) {
+#if defined _SC_NPROCESSORS_ONLN
+ delta_search_threads = sysconf(_SC_NPROCESSORS_ONLN);
+#elif defined _SC_NPROC_ONLN
+ delta_search_threads = sysconf(_SC_NPROC_ONLN);
+#endif
+ if (delta_search_threads == -1)
+ perror("Could not detect number of processors");
+ if (delta_search_threads <= 0)
+ delta_search_threads = 1;
+ }
+#endif
+
prepare_packed_git();
if (progress)
--
1.5.4.1.40.gdb90
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| Eric Paris | TALPA - a threat model? well sorta. |
| Vladislav Bolkhovitin | Re: Integration of SCST in the mainstream Linux kernel |
| Andrew Morton | Re: [BUILD-FAILURE] 2.6.26-rc8-mm1 - x86 - __ptep_modify_prot_start() missing |
| Bodo Eggert | Re: [PATCH] x86: provide a DMI based port 0x80 I/O delay override. |
git: | |
| Pavel Roskin | Implementing branch attributes in git config |
| Jon Smirl | Importing Mozilla CVS into git |
| Jon Smirl | Figured out how to get Mozilla into git |
| Jakub Narebski | Re: VCS comparison table |
| Richard Stallman | Real men don't attack straw men |
| Adam Getchell | Re: About Xen: maybe a reiterative question but .. |
| carlopmart | About Xen: maybe a reiterative question but .. |
| Bertram Scharpf | First install: Grub doesn't find partitions |
| Waskiewicz Jr, Peter P | RE: [PATCH 2/3][NET_BATCH] net core use batching |
| Jeff Kirsher | [PATCH 1/3] e1000e: add support for the 82567LM-4 device |
| Ayaz Abdulla | [PATCH] forcedeth: msi interrupts |
| Corey Hickey | [PATCH 10/10] Use nested compat attributes to pass parameters. |
