08.05.2025 12:35, Stuart Henderson пишет: > On 2025/05/08 10:33, Kirill A. Korinsky wrote: >> Klemens, Benoit, >> >> rovert@ had noticed that git out of the box uses as many threads as the >> system has CUPs. claudio@ had pointed that it is quite bad idea and use an >> example that ld.lld with -Wl,--threads=1 reduces the configure time by 15% >> and system time by 40%. >> >> So, here the diff which replaces 0 threads to 1 by default where it isn't 1 >> already, and disabled try to use threads in name-hashing. >> >> Are you ok with it? > > Certainly using the full number of online CPUs is a poor choice on > OpenBSD, especially on systems with a large number of cores. > > FWIW I showed a shorter diff when this was mentioned (patch online_cpus > to cap, I picked 4 out of the air, I do think there's some benefit to >1 > in many cases but I didn't do a comparison) - that would also cover > anywhere else that uses online_cpus (now and future).
This looks better than the initial patch, won't need user interaction like my config file does and provides dynamic, reasonble behaviour. Please provide a brief patch comment. If you agree that it is worth mentioning in README or MESSAGE so users learn about this, I'd like that, too. OK kn > Index: patches/patch-thread-utils_c > =================================================================== > RCS file: /cvs/ports/devel/git/patches/patch-thread-utils_c,v > diff -u -p -r1.2 patch-thread-utils_c > --- patches/patch-thread-utils_c 11 Mar 2022 18:50:06 -0000 1.2 > +++ patches/patch-thread-utils_c 8 May 2025 09:33:12 -0000 > @@ -3,20 +3,22 @@ Use sysconf(_SC_NPROCESSORS_ONLN) to pro > Index: thread-utils.c > --- thread-utils.c.orig > +++ thread-utils.c > -@@ -25,9 +25,10 @@ int online_cpus(void) > +@@ -24,10 +24,12 @@ int online_cpus(void) > + return 1; > #else > #ifdef _SC_NPROCESSORS_ONLN > ++#define MIN(a,b) (((a)<(b))?(a):(b)) > long ncpus; > -#endif > > -#ifdef GIT_WINDOWS_NATIVE > + if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0) > -+ return (int)ncpus; > ++ return MIN((int)ncpus, 4); > +#elif defined(GIT_WINDOWS_NATIVE) > SYSTEM_INFO info; > GetSystemInfo(&info); > > -@@ -55,11 +56,6 @@ int online_cpus(void) > +@@ -55,11 +57,6 @@ int online_cpus(void) > if (!sysctl(mib, 2, &cpucount, &len, NULL, 0)) > return cpucount; > #endif /* defined(HAVE_BSD_SYSCTL) && defined(HW_NCPU) */ >