From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS47066 71.19.144.0/20 X-Spam-Status: No, score=-1.9 required=3.0 tests=AWL,BAYES_00, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.raindrops.general Subject: [PATCH 1/3] raindrops: favor configured processor count over online count Date: Thu, 11 Apr 2013 23:28:22 +0000 Message-ID: <1365722904-889-1-git-send-email-normalperson@yhbt.net> References: <1365722904-889-1-git-send-email-normalperson@yhbt.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1365722937 12609 80.91.229.3 (11 Apr 2013 23:28:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Apr 2013 23:28:57 +0000 (UTC) To: raindrops@librelist.org Original-X-From: raindrops@librelist.org Fri Apr 12 01:29:01 2013 Return-path: Envelope-to: gclrrg-raindrops@m.gmane.org In-Reply-To: <1365722904-889-1-git-send-email-normalperson@yhbt.net> List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: raindrops@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.raindrops.general:105 Archived-At: Received: from zedshaw2.xen.prgmr.com ([71.19.156.177]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UQQvN-0001UP-9u for gclrrg-raindrops@m.gmane.org; Fri, 12 Apr 2013 01:29:01 +0200 Received: from zedshaw2.xen.prgmr.com (unknown [IPv6:::1]) by zedshaw2.xen.prgmr.com (Postfix) with ESMTP id 3617073DEB for ; Thu, 11 Apr 2013 23:29:19 +0000 (UTC) The runnable CPUs of a process may change over the lifetime of the process. So favor the count of configured processor count since that is more likely to be stable. We do not currently do not have special handling for hot-plugging/removal of CPUs on systems that may load raindrops in a single CPU state. --- ext/raindrops/raindrops.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/raindrops/raindrops.c b/ext/raindrops/raindrops.c index 6cc0d12..65c16e7 100644 --- a/ext/raindrops/raindrops.c +++ b/ext/raindrops/raindrops.c @@ -326,11 +326,13 @@ void Init_raindrops_linux_inet_diag(void); void Init_raindrops_linux_tcp_info(void); #endif -#ifndef _SC_NPROCESSORS_ONLN -# ifdef _SC_NPROC_ONLN -# define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN +#ifndef _SC_NPROCESSORS_CONF +# if defined _SC_NPROCESSORS_ONLN +# define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_ONLN +# elif defined _SC_NPROC_ONLN +# define _SC_NPROCESSORS_CONF _SC_NPROC_ONLN # elif defined _SC_CRAY_NCPU -# define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU +# define _SC_NPROCESSORS_CONF _SC_CRAY_NCPU # endif #endif @@ -359,8 +361,8 @@ void Init_raindrops_ext(void) VALUE cRaindrops = rb_define_class("Raindrops", rb_cObject); long tmp = 2; -#ifdef _SC_NPROCESSORS_ONLN - tmp = sysconf(_SC_NPROCESSORS_ONLN); +#ifdef _SC_NPROCESSORS_CONF + tmp = sysconf(_SC_NPROCESSORS_CONF); #endif /* no point in padding on single CPU machines */ if (tmp == 1) -- 1.8.2.279.g631bc94