Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123379 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 CAB721A009C for ; Tue, 21 May 2024 12:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1716295211; bh=1IBbRbFdDxupeZygA1SDC8d529jmvKSam5jZpI7weEE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SqcUIGZxF95y2kPHhqIs2cajfs8mhVXoqznvWOQC1+UyfD2Kr+D8DQWEwBHOWMGBm d/j9bVsJBe8EcSuzyvudOoMd0D1vDnaI0jSxwOCqdILE0evvhfGWralOeY6HNia/Uf SbSGw8OrQ5+gcFKHwnIiLAQJaegF+5Js7z9fU2CSYNCr5OPoUPSLob/tkqvT/7Ga4V CV7tuG0tEpzU0C9wkLkuJpl+hI/L+x6dDoNY4krQHHMMBuOTHQ80zDOuSWTXTgXiIp iatDJU4/Y58yaikRN8D+jilcCcO0cQjyHyS2DkZkxv5pJHyoQu6hR4Mk6E1q7sQQhZ axW4b7xNYU8Kg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5FF8018007B for ; Tue, 21 May 2024 12:40:10 +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-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 ; Tue, 21 May 2024 12:40:09 +0000 (UTC) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5755fafa5a7so3781504a12.1 for ; Tue, 21 May 2024 05:39:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716295153; x=1716899953; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1IBbRbFdDxupeZygA1SDC8d529jmvKSam5jZpI7weEE=; b=FqEZNzOoN2+SgpIWNbE6HD0yf7556U1TJLYdjBtFfJXw+QRFV/GryHd54j5hAV6jAE EgFnd5n9uOijpN/ENj+M8bIKjqzRcxK0JfkoELFfI/9nCV1zzRc4malkf/1hUQQUOMcu nX7ChZpJiJN/gKAxXa44tN1xtj+wuOBIm/xXzRFJDC42CxwQDzalyqP75UU7oG7uwR6q SPcYYijRikl8xjJ+9mDMb1fXlbYBu0dKbbjzPbluoELfmOQ6IByUPK3VRyKuM4KFFdGy MqsFo8VuVWFe+Be0cXm8CqxUKlPmcM5HDsdwM24AjRpz5w9O7H2/MmX52+BKg81Pehs1 2pZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716295153; x=1716899953; h=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=1IBbRbFdDxupeZygA1SDC8d529jmvKSam5jZpI7weEE=; b=C51mF5qef06wPsQcrjbBARnx2e4Ls2eyKHnNEPo5FG4TOuMcHmqERNG99GhdfkJwMG T8rDds459cQ+dgYgVwCqbqGLS3n2mZk8pY/L9mMk+H6ay5w3hfO3sY01nhf2SG/aAASa 4Km9p1lBdOMiGQloPFPHwhkt4bfwyWV/qqPYiAFUUkx4r/C2yvU2NgWWEGIKJ4W7SGqG o677FHxfCI/7YEsSmvs1j1RnhXlfWKDwQUTheTizgtTYMf07DGPDvdceX6y2IhVKsJbe MEqX0SV2Jb6uv9zFhiWr7ZziAACPon2Pnt8vjsOm87MSc5M3+uxxvmwibJTY5kbKWGpM sRyw== X-Gm-Message-State: AOJu0YxrcFhBha5J5g9ryEx9tNbbc2HeuDWPiV8qxn336JxWS0MNPmEw lxSIC8KiEl3NteBH1SeuWSOR36REBP2er6lQA+XGuLX1FAPi9AHnOGTb5ZSMPQW/8RP/yoIJNPO kN1WsPJMWyjZwMoV62qB/vkg7HNQ= X-Google-Smtp-Source: AGHT+IFV/fOV1oRAWza/LT7uB8/aHIQCa+a2ZPgLWRMpuMK91UAdjN+po9mvcNnTnNz5dltYJFscO+XIkPOteu+8ggI= X-Received: by 2002:a17:906:a24e:b0:a59:aae5:b0bc with SMTP id a640c23a62f3a-a5a2d5d494fmr1871361366b.42.1716295152854; Tue, 21 May 2024 05:39:12 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 21 May 2024 14:39:01 +0200 Message-ID: Subject: Re: [PHP-DEV] Switching max_execution_time from CPU time to wall-clock time and from SIGPROF to SIGALRM To: Robert Landers Cc: PHP internals Content-Type: text/plain; charset="UTF-8" From: arnaud.lb@gmail.com (Arnaud Le Blanc) Hi Robert, > This sounds like a bug with Mac vs. a PHP issue. This is what I believe as well. FWIW I was able to reproduce the issue outside of PHP [2]. I've reported the bug to Apple, but I don't expect it to be fixed quickly, if at all. > 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. Good point. Do you have references about ITIMER_REAL using a non-monotonic clock, besides the lack of specification regarding the clock? Based on experiments and the code [1], I think that ITIMER_REAL uses a monotonic clock on MacOS. It's not ideal to rely on that, and we should use a better specified timer mechanism if we eventually switch to wall-clock time on all platforms, but it seems reasonable as a workaround for the ITIMER_PROF bug on MacOS/Apple Silicon. > 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. Unfortunately ITIMER_VIRTUAL is not really useful as a max_execution_time implementation as it will basically never fire in a syscall-heavy workload. E.g. after replacing ITIMER_PROF by ITIMER_VIRTUAL in [2], the program runs for well over the specified time before receiving a signal, despite consuming a considerable amount of resources. [1] https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/kern/kern_time.c#L432 [2] https://gist.github.com/arnaud-lb/012195a2fe4d3a2c1bff530a73ae6b11 Best Regards, Arnaud