From 69196e41ec9c5a6ce8efd370fb8582f66667bcf7 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 14 Jan 2012 10:31:01 -0500 Subject: [PATCH] Windows: restrict service to 2 cpus by default Performance drops off considerably when the number of processors increases due to lock contention and the cm_SyncOp wait processing. If the MaxCPUs registry value is not set, limit ourselves to two. Setting MaxCPUs to zero permits use of all CPUs. Change-Id: I4bae328ed589811b0ea2a514501a0c1aa74e8015 Reviewed-on: http://gerrit.openafs.org/6555 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/afsd_init.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/WINNT/afsd/afsd_init.c b/src/WINNT/afsd/afsd_init.c index eff213c80..d4dc292bf 100644 --- a/src/WINNT/afsd/afsd_init.c +++ b/src/WINNT/afsd/afsd_init.c @@ -610,7 +610,11 @@ afsd_InitCM(char **reasonP) dummyLen = sizeof(maxcpus); code = RegQueryValueEx(parmKey, "MaxCPUs", NULL, NULL, (BYTE *) &maxcpus, &dummyLen); - if (code == ERROR_SUCCESS) { + if (code != ERROR_SUCCESS) { + maxcpus = 2; + } + + { HANDLE hProcess; DWORD_PTR processAffinityMask, systemAffinityMask; @@ -619,7 +623,7 @@ afsd_InitCM(char **reasonP) if ( hProcess != NULL && GetProcessAffinityMask(hProcess, &processAffinityMask, &systemAffinityMask) ) { - int i, n, bits; + int i, n, bits, cpu_count = 0; DWORD_PTR mask, newAffinityMask; #if defined(_WIN64) @@ -627,19 +631,26 @@ afsd_InitCM(char **reasonP) #else bits = 32; #endif - for ( i=0, n=0, mask=1, newAffinityMask=0; i