Subject: bug#67502: closed (Re: bug#67502: [Cuirass] ‘cuirass remote-worker’ gets the CPU count wrong on the OverDrive)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 28 Nov 2023 15:30:02 +0000

Your bug report

#67502: [Cuirass] ‘cuirass remote-worker’ gets the CPU count wrong on the OverDrive

which was filed against the guix package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
67502: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67502
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#67502: [Cuirass] ‘cuirass remote-worker’ gets the CPU count wrong on the OverDrive
From: Ludovic Courtès <[email-masked]>
To: [email-masked]
Date: Tue, 28 Nov 2023 16:28:50 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Ludovic Courtès <[email-masked]> skribis:

> ludo@dover ~$ sudo herd status cuirass-remote-worker
> Status of cuirass-remote-worker:
>   It is started.
>   Running value is 21279.
>   It is enabled.
>   Provides (cuirass-remote-worker).
>   Requires (avahi-daemon guix-daemon networking).
>   Will be respawned.
> ludo@dover ~$ guile -c '(pk (getaffinity 21279))'
>
> ;;; (#*1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)

This was due to ‘run-fibers’ binding one thread per CPU core.  Thus,
calling ‘getaffinity’ from within ‘run-fibers’ shows only one CPU and
likewise ‘current-processor-count’ returns 1.

Fixed in Cuirass commit 87a6d6ea7ae79fdf487bbcfd44bb3dce2d7c6e82.

Ludo’.

Subject: [Cuirass] ‘cuirass remote-worker’ gets the CPU count wrong on the OverDrive
From: Ludovic Courtès <[email-masked]>
To: [email-masked]
Date: Tue, 28 Nov 2023 10:09:42 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

On the OverDrive (AArch64), ‘cuirass remote-worker’ (1.2.0-1.bdc1f9f) says:

  starting 2 workers (parallelism: 1 cores) for server at 10.0.0.1

Instead it should use two cores for each worker:

--8<---------------cut here---------------start------------->8---
ludo@dover ~$ guile -c '(use-modules (ice-9 threads)) (pk (current-processor-count))'

;;; (4)
ludo@dover ~$ guile -c '(use-modules (ice-9 threads)) (pk (ceiling-quotient (current-processor-count) 2))'

;;; (2)
ludo@dover ~$ nproc
4
--8<---------------cut here---------------end--------------->8---

Since ‘current-processor-count’ is implemented indirectly in terms of
‘sched_getaffinity’, this suggests that the process starts with a bogus
affinity mask.  (Time passes…)  That’s indeed the case:

--8<---------------cut here---------------start------------->8---
ludo@dover ~$ sudo herd status cuirass-remote-worker
Status of cuirass-remote-worker:
  It is started.
  Running value is 21279.
  It is enabled.
  Provides (cuirass-remote-worker).
  Requires (avahi-daemon guix-daemon networking).
  Will be respawned.
ludo@dover ~$ guile -c '(pk (getaffinity 21279))'

;;; (#*1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
--8<---------------cut here---------------end--------------->8---

Compare to the affinity mask on x86_64-linux-gnu:

--8<---------------cut here---------------start------------->8---
ludo@guix-hpc3 ~$ sudo guile -c '(pk (getaffinity 1817))'

;;; (#*1111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
--8<---------------cut here---------------end--------------->8---

Interesting that the initial affinity mask differs on aarch64-linux-gnu
compared to x86_64-linux-gnu.

Ludo’.