login
Header Space

 
 

[PATCH 1/2] pack-objects: Allow setting the #threads equal to #cpus automatically

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <ae@...>
Cc: Nicolas Pitre <nico@...>, Git Mailing List <git@...>
Date: Monday, February 11, 2008 - 10:55 pm

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
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] RFC: git lazy clone proof-of-concept, Jan Holesovsky, (Fri Feb 8, 1:28 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Fri Feb 8, 4:16 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jakub Narebski, (Fri Feb 8, 3:00 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jan Holesovsky, (Sat Feb 9, 11:27 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jakub Narebski, (Sun Feb 10, 9:20 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Sat Feb 9, 11:10 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Sun Feb 10, 12:43 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Sun Feb 10, 3:50 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Brandon Casey, (Thu Feb 14, 3:41 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Thu Feb 14, 4:11 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Thu Feb 14, 3:58 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Sun Feb 10, 2:47 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Tue Feb 12, 4:37 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Thu Feb 14, 3:20 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jan Holesovsky, (Fri Feb 15, 5:34 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jakub Narebski, (Thu Feb 14, 4:05 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Brandon Casey, (Thu Feb 14, 5:08 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Thu Feb 14, 5:04 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jakub Narebski, (Thu Feb 14, 5:59 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jan Holesovsky, (Fri Feb 15, 5:43 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Thu Feb 14, 7:38 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jakub Narebski, (Thu Feb 14, 9:07 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Brian Downing, (Thu Feb 14, 7:51 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Thu Feb 14, 8:08 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Thu Feb 14, 9:41 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Shawn O. Pearce, (Sun Feb 17, 4:18 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Sun Feb 17, 2:44 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Junio C Hamano, (Sun Feb 17, 5:05 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Brian Downing, (Thu Feb 14, 7:57 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Thu Feb 14, 4:16 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jon Smirl, (Tue Feb 12, 5:25 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Linus Torvalds, (Tue Feb 12, 5:08 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jon Smirl, (Tue Feb 12, 5:36 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Linus Torvalds, (Tue Feb 12, 5:59 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Linus Torvalds, (Tue Feb 12, 6:25 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jon Smirl, (Tue Feb 12, 6:43 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Linus Torvalds, (Tue Feb 12, 7:39 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Tue Feb 12, 5:05 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Sun Feb 10, 3:42 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jon Smirl, (Sun Feb 10, 4:11 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jon Smirl, (Sun Feb 10, 1:01 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Sun Feb 10, 1:36 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Sun Feb 10, 1:22 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jakub Narebski, (Sun Feb 10, 9:42 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Sun Feb 10, 10:04 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jakub Narebski, (Mon Feb 11, 6:11 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jon Smirl, (Fri Feb 8, 3:26 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Harvey Harrison, (Fri Feb 8, 4:19 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jon Smirl, (Fri Feb 8, 4:24 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Harvey Harrison, (Fri Feb 8, 4:25 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jon Smirl, (Fri Feb 8, 4:41 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Fri Feb 8, 4:09 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Andreas Ericsson, (Mon Feb 11, 6:13 am)
[PATCH 1/2] pack-objects: Allow setting the #threads equal t..., Brandon Casey, (Mon Feb 11, 10:55 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Mike Hommey, (Fri Feb 8, 2:49 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jan Holesovsky, (Sat Feb 9, 11:06 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Fri Feb 8, 3:04 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Fri Feb 8, 2:20 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Harvey Harrison, (Fri Feb 8, 2:14 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jan Holesovsky, (Sat Feb 9, 10:27 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Fri Feb 8, 2:03 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Jan Holesovsky, (Sat Feb 9, 10:25 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Marco Costalba, (Sun Feb 10, 3:23 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Sun Feb 10, 8:08 am)
Re: [PATCH] RFC: git lazy clone proof-of-concept, David Symonds, (Sun Feb 10, 12:46 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Sun Feb 10, 1:45 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Sun Feb 10, 3:45 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Johannes Schindelin, (Sun Feb 10, 4:32 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Mike Hommey, (Sat Feb 9, 6:05 pm)
Re: [PATCH] RFC: git lazy clone proof-of-concept, Nicolas Pitre, (Sat Feb 9, 7:38 pm)
speck-geostationary