From 307cd980312e9550f5ac847e02d979ef3d69128a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= <5175937+theofidry@users.noreply.github.com> Date: Tue, 6 Aug 2024 02:14:31 +0200 Subject: [PATCH] feat: Do not check the load limit by default (#144) --- src/CpuCoreCounter.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/CpuCoreCounter.php b/src/CpuCoreCounter.php index a6cd7e4..8c8b55b 100644 --- a/src/CpuCoreCounter.php +++ b/src/CpuCoreCounter.php @@ -65,10 +65,15 @@ public function __construct(?array $finders = null) * previous example, it will return 5 cores. How busy is * the system is determined by the system load average * (see $systemLoadAverage). - * @param float|null $systemLoadAverage The system load average. If not provided, it will be - * retrieved using `sys_getloadavg()` to check the load - * of the system in the past minute. Should be a positive - * float. + * @param float|null $systemLoadAverage The system load average. If passed, it will use + * this information to limit the available cores based + * on the _available_ resources. For instance, if there + * is 10 cores but 3 are busy, then only 7 cores will + * be considered for further calculation. If set to + * `null`, it will use `sys_getloadavg()` to check the + * load of the system in the past minute. You can + * otherwise pass an arbitrary value. Should be a + * positive float. * * @see https://php.net/manual/en/function.sys-getloadavg.php */ @@ -76,7 +81,7 @@ public function getAvailableForParallelisation( int $reservedCpus = 0, ?int $countLimit = null, ?float $loadLimit = null, - ?float $systemLoadAverage = null + ?float $systemLoadAverage = 0. ): ParallelisationResult { self::checkCountLimit($countLimit); self::checkLoadLimit($loadLimit);