Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123332 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id DC70D1A009C for ; Fri, 17 May 2024 14:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1715955095; bh=7pQH8C1HEEuqwA5CFRPMm18WrnP2J4L6Tp2LEuHTeL8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=U3b6odHCM4ZuYZCFzDhR4fAEECN1weKKcw9nR8uojoR4fX9ZUWlBdUZS5YDBTS3Dg Z6ZDHeC8X8mXZtAisvkIlfdB7BfR4Jv+n7Kc4FYcfD5007jpqYZEK5S3Q+8DMd/YYh N4cFLaiZbQQmPT9cgX2iL6Ywkd0zdxyloy99HX/IwdV5VsWVsYJJdod/VPfwkWfDVU YhPBhhgQNo3Y1hDtzKDFyf0caC1atylLvhbnC8LrZ7YvDNLLI4cLJoSv60uKIS1F49 kUXviyh5S+nAlS3PSDmMQRqbhFDOIqGXN7Gt94AtlO86lQgPjaA2aY5Ot6I1WcH+QK O09eHBECuSVIA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7A7C1180068 for ; Fri, 17 May 2024 14:11:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 17 May 2024 14:11:34 +0000 (UTC) Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-51f0602bc58so611839e87.0 for ; Fri, 17 May 2024 07:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715955039; x=1716559839; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7pQH8C1HEEuqwA5CFRPMm18WrnP2J4L6Tp2LEuHTeL8=; b=X/gwb0FFwswEK+dha2r9rl2pv+2VqH8Qzj/oX47D19tKErbddPfIAXTeoQanBkZyxU glpuRvJJ6Sm970daWTLWQ4yA+i8vth2KPHQvyB3KHWAYjcjWb7Nlq02MnNnw9c4SF+z0 pFfu/sh1GV3qWji+ynbdBLNy3taY6xiyB0kD6zkHTn7esZuK3z+rtYryrYmbJu3mFQ7C pitfJrftDbrAFKbKykjepc0kVQ2mZ/MjmF2hhp89Vclun2syrfy3rr9Ui5xL4lYg9ZcC H1FiXjwa9shxbts0HJbjXuz6atAMYBSia6JaNiIix6L87Rb2++8n5varh+3TRAx2fqUL HTcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715955039; x=1716559839; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7pQH8C1HEEuqwA5CFRPMm18WrnP2J4L6Tp2LEuHTeL8=; b=dQ1/rRVE/+FfnI2vfRRDJW8PniaKFFDH0tskM1L1hI9EsEvNBcUOmmhdcfwbBM4VCl auJ3Gr3v1EuPPqeVzSgWJmahDRNYn4edQ2UPqNFuGPCcGkQUsGdEFztSRpeHEXwGHHXw uDIdTCAB13Bedw+KQQOmUpDPiJcEtU/GQcZa1k9ZLf0u+4R8gF79/lgXV6Rbyi5aeL1V q8Lmyg0W/bknSLjQFLDNq+z0oeKnegxWAtzJW7DvP5WaXJW5AdYPAuUO/w0+UGLc2sOh uZm2JOhn2duNx2hVvIHlcrJM/cbG2/PMSVDX2xXmhIm+6UC4zjd7PZh3eQNjYpElPa7p iCZQ== X-Gm-Message-State: AOJu0YwshxYHHj6oV1MIKmdZYeu+Cw9CRdVR1fbjh8+i/Y6TZFcKvvJq KM/9Y2OTsk7bIZrzT1rNkJIhhOCWVzmWaqOHblFHEz7JCF6mQwcYRMAkfsaUOU5m4iZZuc+VOEj PHJ+32F5sfaMnBlcM4heEdKfErUu9dChZalo= X-Google-Smtp-Source: AGHT+IEgilye32ok5L7IFoFZwDu7zUCAF82P4cJ519oN+MpGJyaQiqocq8gv71aQRp+TQRn5IP3aNABsZDjMStM4pcU= X-Received: by 2002:ac2:414c:0:b0:51f:d790:bb58 with SMTP id 2adb3069b0e04-5220e474d20mr5494132e87.18.1715955038658; Fri, 17 May 2024 07:10:38 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 17 May 2024 16:10:26 +0200 Message-ID: Subject: Re: [PHP-DEV] Switching max_execution_time from CPU time to wall-clock time and from SIGPROF to SIGALRM To: Arnaud Le Blanc Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: landers.robert@gmail.com (Robert Landers) On Fri, May 17, 2024 at 3:50=E2=80=AFPM Arnaud Le Blanc wrote: > > Hi internals, > > There is an issue with max_execution_time on MacOS, probably only > MacOS 14 on Apple Silicon, that causes timeouts to fire too early [1]. > max_execution_time is implemented with setitimer(ITIMER_PROF) on this > platform, and the SIGPROF signal is delivered too early for some > reason. Switching to ITIMER_REAL appears to fix the issue, and Manuel > Kress opened a PR [3]. > > Are there objections against switching to ITIMER_REAL on MacOS (Apple > Silicon only) in all currently supported PHP versions? (next 8.2.x, > 8.3.x, 8.x) > > Apart from fixing the issue, this would introduce the following minor > breaking changes: > > - max_execution_time on MacOS would be based on wall-clock time rather > than CPU time, so the time spent in I/O, sleep(), and syscalls in > general would count towards the max_execution_time > - The SIGALRM signal would be used instead of the SIGPROF signal > (using SIGALRM conflicts with pcntl_alarm(), but SIGPROF conflicts > with profilers). As noted by Dmitry, it also conflicts with sleep() on > some platforms, however this should be safe on MacOS. > > Currently max_execution_time is based on wall-clock time on ZTS and > Windows, and CPU time otherwise. On Linux and FreeBSD, wall-clock time > can also be used when building with > --enable-zend-max-execution-timers. M=C3=A1t=C3=A9 proposed to add a wall= -clock > based timeout in the past [2] but the discussion has stalled. Any > thoughts about eventually switching other platforms to wall-clock > timeouts in the next 8.x ? > > TL;DR: > - Any objection about using wall-clock max_execution_time and SIGALRM > on MacOS Apple Silicon in all supported versions? > - Thoughts about using wall-clock timeouts on all platforms in the next 8= .x ? > > [1] https://github.com/php/php-src/issues/12814 > [2] https://github.com/php/php-src/pull/6504 > [3] https://github.com/php/php-src/pull/13567 > > Best Regards, > Arnaud This sounds like a bug with Mac vs. a PHP issue. That being said, the biggest issue between changing these clocks is that ITIMER_PROF is (practically, but not explicitly) monotonic. ITIMER_REAL can go backwards (NTP clock adjustments) which might have interesting side-effects if the clock is adjusted. The problem might actually be using ITIMER_PROF, which "Measures CPU time used by the process, including both user space and kernel space" and usage of sockets/threads might give an "accelerated" value while maybe ITIMER_VIRTUAL is the one we should be using since it "Measures CPU time used by the process (user space)" which won't count kernel timings. Robert Landers Software Engineer Utrecht NL