Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126150 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 48F031A00BD for ; Fri, 20 Dec 2024 22:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1734733931; bh=Seb8u3eUJtMn5Qq7KlW0SPnh5n35oFsZDUtAl4D6JtE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=TMzEdOUtpCkechP/C0r/d7KaIx7Ro7Q9LpGDmHqPC2uPQu653EjsMzbO+I9kDfQdE rhk05w5yiUejIkdqkaFEeRxPlXqertn+iozqsUBwPexqE/O1coQimv5q5pnbXa8nIj Zds3Uo+tVSbuANRkp8LUkoocVkRdBVDCmjkv83ouUpDJQqMPTXhNLXNTt7ZHnEqjJs K+9cUDYOVnU0Uapth6G3omzn69408GId4ltVKPJP/i+qbirBHh7z04xhu367ddN8Z6 +t/lNxKxYsB4JGZFpiNt3a1f3oUsVep/fllvFX5E/zuV7losG7Gg7DCCT3y0Un+pxD LgrARJzGcTvWA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BAADB180069 for ; Fri, 20 Dec 2024 22:32: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, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.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, 20 Dec 2024 22:32:10 +0000 (UTC) Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5d41848901bso4416373a12.0 for ; Fri, 20 Dec 2024 14:35:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734734110; x=1735338910; 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=i2kTBp1JJVq5ygoNCKGNBG1Sfd6GAQ9TrEJfHXX3CPs=; b=dSq9hVlt/T7qxdB5BOHk+nTOsH+JkOhF7XgZ2mRdgzluIkK4ayxVjmojMpd5gbmWWF DnuwLudDDoU0P4Z2wLx5mOZ/2GSXMQ2XIXXsz80Zfayiin034ymkrVmTgqy9rKFmBNfQ F6r+XowWaLHya+A0b8cuDXefInwJEMAUMbqRQZWHCpgSJ9eMfv2xOn+rwOEOSKGV5p1Y wCmtC6htzXkS+SjhzOpTmvsJ90Voq/UIl0sH0YefjSXxfYT7uj7fxbIgC2Co7KTmU28x 5lWgGEf2rLd2gjvV4v7z7euHV0c+LbWvZFBIGFKFOPEdL87DUfm+wkt3SlU3ZP+/SHAg sq7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734734110; x=1735338910; 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=i2kTBp1JJVq5ygoNCKGNBG1Sfd6GAQ9TrEJfHXX3CPs=; b=OGttQxHUOx3uA9R7uNTN2pjZ7OiL/YmS3wF5aeKCgssYUdUJzGdFbxeB022qqtEvup LHRs20uaTbrWANdE8MutVyBXK4t6RY07/WjLmriIjEygkb8Pbrjk0W34IGoI/dGPNHcC XAbteW+50Jjkkr0IIwl55XY39CGgPmcWciuCtr/T3q5VXNQX07r3zTzeyWGZTjxB2V9W 3sIUydPuu5JFax6mYYcsONCysjSWcAwF2TTC7ff1yWPfMkSaRHE5ifFDzlGeQMVYX8WJ gpq+/yrQhGzIM4kl3mEP1SC33b0LmQKoDsT+K8sEA9JlWgW+d89ljgAJiQ1JiEpk5qnM GI/w== X-Gm-Message-State: AOJu0YxUhAy6+oEZ2cQRUY+mr+u0uPRnaLAC6LmUoSX5N/bHfsmQ3Zk8 Qj3T0e5zg9nTG4AFPHh2qDv0YMEEmWzMLexskZVx59HKgxr1brwSBZCSrQFOeTSdF7yLoPZoTW2 sjRbkO0S/fFhloEjohzAGSuUWm93atw== X-Gm-Gg: ASbGncuiZPfpd1LXFDjvCGn2Iq/t+YuN10PtF80J2t1KlYJ2UBI2nnnzFe2rJK8iAYT uZC7onz7vXyUmYis09R9S6+0l0mLHxgacPprK/KahRA04cV4Rekg6K8X2XQuC0GDABX01 X-Google-Smtp-Source: AGHT+IFhpwXdV/HArZ9es/EW8Sg6ZglpUJLysphBgGxrllVbz8IYKqtFuIHMruKJK4/CGxpepX2ILIZp0lgFvZUiRlg= X-Received: by 2002:a05:6402:520c:b0:5d0:d328:3a43 with SMTP id 4fb4d7f45d1cf-5d81e71a038mr4048889a12.6.1734734109932; Fri, 20 Dec 2024 14:35:09 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <27531d9d-9bfe-4acc-b9ab-80b1017e3038@app.fastmail.com> In-Reply-To: <27531d9d-9bfe-4acc-b9ab-80b1017e3038@app.fastmail.com> Date: Fri, 20 Dec 2024 23:34:42 +0100 Message-ID: Subject: Re: [PHP-DEV] Discussion: Remove file statcache? To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000006708110629bb42d1" From: kjarli@gmail.com (Lynn) --0000000000006708110629bb42d1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 20, 2024 at 8:29=E2=80=AFPM Larry Garfield wrote: > Background: PHP has a not-often-considered feature, the stat-cache. That > is, the runtime caches the OS stat() call for files, so that subsequent > reads on the same file can be faster. However, it's even less realized > that it's a single-file cache. It literally only applies when you try to > do two file-infomation operations on the same file in rapid succession, > without any other file reads in between. > > For more info: > https://tideways.com/profiler/blog/the-php-stat-cache-explained > > Because it's so rarely relevant, in the cases it is relevant, it can be > quite a surprise, and a surprise causing weird and hard to explain cachin= g > bugs in applications. > > The cache also dates from 20 years ago, when Rasmus added it (and the > realpath cache) in Yahoo's forked PHP 4, and then it got integrated into > PHP 5. However, hard drives are vastly faster than they were then, and > operating systems are vastly more efficient than they were then. > > There's been some discussion about making the cache disable-able, though > the consensus now seems to be leaning toward getting rid of it outright: > > https://github.com/php/php-src/pull/17178 > > Arnaud ran some quick benchmarks and found that disabling it has a less > than 1% impact on Symfony and WordPress. > > https://github.com/php/php-src/pull/17178#issuecomment-2554323572 > > Before we go any further, is there appetite among the voting population t= o > remove it? clearstatcache() and similar functions would get stubbed out = as > no-ops, but otherwise we'd just hand the responsibility back to the OS > where it belongs, which seems so far like it would be almost an > unmeasurable performance difference but remove some surprise complexity. > > Would you support such a removal? > What additional data would you need to make the case for such removal? > > -- > Larry Garfield > larry@garfieldtech.com This gets a +1 from me. I've had bugs that I suspected were caused by this cache, but I was never able to confirm it until putting clearstatcache() in production. That's not a workflow I'd like to follow, and it has wasted enough of my time. --0000000000006708110629bb42d1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Fri, Dec 20,= 2024 at 8:29=E2=80=AFPM Larry Garfield <larry@garfieldtech.com> wrote:
Background: PHP has a not-often-considered= feature, the stat-cache.=C2=A0 That is, the runtime caches the OS stat() c= all for files, so that subsequent reads on the same file can be faster.=C2= =A0 However, it's even less realized that it's a single-file cache.= =C2=A0 It literally only applies when you try to do two file-infomation ope= rations on the same file in rapid succession, without any other file reads = in between.

For more info: https://tideways.com/p= rofiler/blog/the-php-stat-cache-explained

Because it's so rarely relevant, in the cases it is relevant, it can be= quite a surprise, and a surprise causing weird and hard to explain caching= bugs in applications.

The cache also dates from 20 years ago, when Rasmus added it (and the realp= ath cache) in Yahoo's forked PHP 4, and then it got integrated into PHP= 5.=C2=A0 However, hard drives are vastly faster than they were then, and o= perating systems are vastly more efficient than they were then.

There's been some discussion about making the cache disable-able, thoug= h the consensus now seems to be leaning toward getting rid of it outright:<= br>
https://github.com/php/php-src/pull/17178

Arnaud ran some quick benchmarks and found that disabling it has a less tha= n 1% impact on Symfony and WordPress.

https://github.com/php/php-src/pull= /17178#issuecomment-2554323572

Before we go any further, is there appetite among the voting population to = remove it?=C2=A0 clearstatcache() and similar functions would get stubbed o= ut as no-ops, but otherwise we'd just hand the responsibility back to t= he OS where it belongs, which seems so far like it would be almost an unmea= surable performance difference but remove some surprise complexity.

Would you support such a removal?
What additional data would you need to make the case for such removal?

--
=C2=A0 Larry Garfield
=C2=A0 larry@ga= rfieldtech.com

This gets a=C2=A0+1 from= me. I've had bugs that I suspected were caused by this cache, but I wa= s never able to confirm it until putting clearstatcache() in production. Th= at's not a workflow I'd like to follow, and it has wasted enough of= my time.
--0000000000006708110629bb42d1--