From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Campbell Barton Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] support for accessing CPU/core count (processor-count) Date: Mon, 11 Oct 2021 09:43:05 +1100 Message-ID: <015c134b-5a13-7665-011b-bc2455d99307@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30321"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 11 00:44:17 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mZhYH-0007ky-4T for ged-emacs-devel@m.gmane-mx.org; Mon, 11 Oct 2021 00:44:17 +0200 Original-Received: from localhost ([::1]:41994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZhYF-0000cf-J5 for ged-emacs-devel@m.gmane-mx.org; Sun, 10 Oct 2021 18:44:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZhXE-0008Md-4d for emacs-devel@gnu.org; Sun, 10 Oct 2021 18:43:12 -0400 Original-Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:38682) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZhXC-0003eO-Mx for emacs-devel@gnu.org; Sun, 10 Oct 2021 18:43:11 -0400 Original-Received: by mail-pg1-x533.google.com with SMTP id s75so9023706pgs.5 for ; Sun, 10 Oct 2021 15:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=+3oGZaVYWh59S9buB0KMfghogu5dZXPqg9RsbqxkiII=; b=BiUC2GpTva/Xiy654CcW06zjvW40ukpJenmQHD5Q+hOQGrajyr5gFZnbE6EayBiKAl y5U6DQPdzOFFrt+4fyWk1riZ2uhhi/NpBR2NOm/zJh0xmYv63/SEvwQUK+r5Oxc2PBzW llCjVrwLvb9LrJx+NBsBwJ5HgA1nK2owuqjMdwMWbkJUt98o7/6RWrWzqlNRHMjkVqph ovJAcvgy7c4Wb7d0n1cWqLN78/RRi6uAzH96SmM5Wflw6GhtMEposfvkZH1IlW4TZ2fT 7DqmCrPYt6Y4yWUKvM21ORd8i22uS1x3k1yCdgkDLZyaEsN4L6RR6BVjmjzCUHcvPypy FqkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=+3oGZaVYWh59S9buB0KMfghogu5dZXPqg9RsbqxkiII=; b=iQwYbXvhmYCgiIxkO50MqCvU+PaAqIKIdY4cul71Pgop3ld8dYYeo8HGl8v9EPbtWI DeG0eAev1TteZLJlRA45WimJkOws2K/65ajLfy+kBTXBqwZVgxjwxkWaJ3hZqPsLFM+l NRH8M9pzCw2MUBkgqC2OgQdY7cNrOVw/L4sge/wsQ4y3V6nTNDru6jomC6z/DyMwoHUL dg0c/wVDUxC7c/96L5ejvz2c0N+N6/Vwis1OuP0j20Wnva+IYJ6jWXTgK+kQIgzRBl44 QBk5auDAo/MwNSTFfIt8qz6wgjPrrJAgb8r6BDRagOCkOvhNbbuCCysSOzDGo/WBPh24 8AyA== X-Gm-Message-State: AOAM533Eg9iVNXHfkzytbFKj9YKxW/3d0tudmB4VmyKwYZrbByGckup2 4oDJIymUoXTZ53dlK7AypxbzjNB1Dhg= X-Google-Smtp-Source: ABdhPJz9ed5AbIHoNiunH4Q4m2cVrmBNwWakdght3/4k7uIhUg5Ao/rxJYORr8B92OOMqqPS6WT6Kg== X-Received: by 2002:a63:2c8b:: with SMTP id s133mr3050330pgs.282.1633905789024; Sun, 10 Oct 2021 15:43:09 -0700 (PDT) Original-Received: from ?IPV6:2402:b801:2844:2100::1? ([2402:b801:2844:2100::1]) by smtp.gmail.com with ESMTPSA id oj1sm5430316pjb.49.2021.10.10.15.43.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Oct 2021 15:43:08 -0700 (PDT) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=ideasman42@gmail.com; helo=mail-pg1-x533.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:276711 Archived-At: On 10/10/21 23:09, Stefan Kangas wrote: > Campbell Barton writes: > >> Hi, this patch adds support for accessing the number of CPU's / cores on >> a system, matching CPython's multiprocessing.cpu_count() [0]. >> >> I've only tested this for Linux, this includes code that should work on >> other platforms, although that would need to be double-checked of course. >> For reference I checked CPython / Blender & Stack-overflow [1] >> >> Accessing this information can be useful to automatically detect the >> number of jobs to run. > > Could we reuse the num_processors_ignoring_omp function in nproc.c in Gnulib? > > From a cursory look, it seems to support also e.g. HP-UX, IRIX. > This makes use of CPU affinity (where possible), which would be appropriate for Emacs spawning operating system level threads. Since Python's multiprocessing is straightforward and widely used, following the same behavior seems reasonable. If CPU affinity becomes an important this could be supported if/when it's needed.