Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126147 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 E10F01A00BD for ; Fri, 20 Dec 2024 20:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1734725273; bh=XOVI1XLCldi9dWFdi+9VCtWfdOCc0oCl9yYooMZ7/eg=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=f4Jl51ZFltH+7iidXa8fT05svZJpxuqJWcRbO90WlNTrPHVPKi+DtQKjGXZlolz4o Zun+E8iGfdkR/3a401ndFDqOJIrgjWf9u7D21dRdol2gB+LgJZxkT8hHUachKjPCGi NkB7hqIfDB8aZHm5U9QT0VzaloDjJuTaa4bVLHdVaVHbQTc32SVAN3DBgH+ULcpbCD clM85kyjaDt45eNiB5nJbm/+NatH8BHyvrIFn0WCFwT6M6eHkvFPvLREjwcc3VpYTG 4Ck729VYjKPHFqNf7aroqgJHsu98AgOIFE1aVGUAarwAD5eEQ9vaoUKcUt9ouzw0hb 9pe1A2xT1htWw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6F6C91801E0 for ; Fri, 20 Dec 2024 20:07:52 +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.8 required=5.0 tests=BAYES_50,DMARC_MISSING, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from supercat.cmpct.info (supercat.cmpct.info [71.19.146.230]) (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 20:07:51 +0000 (UTC) Received: from smtpclient.apple (fctnnbsc38w-142-162-55-237.dhcp-dynamic.fibreop.nb.bellaliant.net [142.162.55.237]) by supercat.cmpct.info (Postfix) with ESMTPSA id 3964057313; Fri, 20 Dec 2024 20:10:51 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51.11.1\)) Subject: Re: [PHP-DEV] Discussion: Remove file statcache? In-Reply-To: <27531d9d-9bfe-4acc-b9ab-80b1017e3038@app.fastmail.com> Date: Fri, 20 Dec 2024 16:10:39 -0400 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <27531d9d-9bfe-4acc-b9ab-80b1017e3038@app.fastmail.com> To: Larry Garfield X-Mailer: Apple Mail (2.3776.700.51.11.1) From: calvin@cmpct.info (Calvin Buckley) On Dec 20, 2024, at 3:26=E2=80=AFPM, Larry Garfield = wrote: >=20 > 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. >=20 > For more info: = https://tideways.com/profiler/blog/the-php-stat-cache-explained >=20 > 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. >=20 > 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. >=20 > 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: >=20 > https://github.com/php/php-src/pull/17178 >=20 > Arnaud ran some quick benchmarks and found that disabling it has a = less than 1% impact on Symfony and WordPress. >=20 > https://github.com/php/php-src/pull/17178#issuecomment-2554323572 >=20 > Before we go any further, is there appetite among the voting = population to 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. >=20 > Would you support such a removal? > What additional data would you need to make the case for such removal? >=20 > --=20 > Larry Garfield > larry@garfieldtech.com At least on the platform I'm supporting (IBM i), filesystem calls can be quite slow. I know it's similar on Windows too. That said, I think getting rid of the stat cache is probably the right call. It's better to do this at the OS or application levels, where they know more about the workload (either because they have a system view, or the app knows what it needs to keep). I haven't measured this yet though.=