Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126189 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 BF3391A00BD for ; Mon, 30 Dec 2024 18:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1735584848; bh=wSF19X+58oOMcQ+znrIUplvxozH07SW5Ta5PYYhwpUc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mXNmZqoSBBRlIKZJQW3VJAciuZPNVW3AZ1bRoNMY0K2Y2Gy/CrmCVBeaVN0N3Y2t5 F7TKU7x3F4ndjznHTA49bvX8MmPJdW7i9PLkYh3g1FewZKYG+YHE6vWmPhSw0Jw+Xo Tyj3FQRChLudYacqI7Oz+CmohosDPLrFO5F03bPgq/ZxNZbqDswgDpFLyEXk2coMgq 9nEWG/2iWtDeFs9WkHkOEBj0e/bX0viJ6Nsrx6x8urCBH+a6i46YMeL2RwfPlxWmfv cdl4tLSKOwn5uV1Gpe+6mOk8fPCDwhIV4WTbdM1/NmK7M7gAREyJbFyJCb61W6EsjL PnRYswD/eP4hw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C80FC18007D for ; Mon, 30 Dec 2024 18:54:07 +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=2.0 required=5.0 tests=BAYES_50,DMARC_NONE, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (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 ; Mon, 30 Dec 2024 18:54:07 +0000 (UTC) Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-5f6497fbccbso3239601eaf.0 for ; Mon, 30 Dec 2024 10:57:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735585025; x=1736189825; 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=wSF19X+58oOMcQ+znrIUplvxozH07SW5Ta5PYYhwpUc=; b=MOfCL2DQeoXs+LCvSuyAo2OC90uUHcOQsJ8Pto4ot+uBacd1ZgPrpP/Mflc4rSV1LN K1bISoWIT/IVGBqeeIpycTXCEUVRHmhpurabH+ZAyO2ppSIeMbZ9rambgmDU9AQxEV9S gOC0pAOmIBI4ugTAc6VaUIB4bBzPjLbw87daAiPSHnfvkvjM0ukRnCY3SlA/Xlu544Lz GJAImhlCo6DG3gFQY6hjbmN35dPrJrUscmn3gts2FaCJyDL2q4HPmBNykmV01/F0nyM+ pPJGHKjQWRU1p7NjHlefKe6ihPLN41lbKiecBUpJF8h5cnbPD1oacYsd+4n4C62pkAOz +eKA== X-Forwarded-Encrypted: i=1; AJvYcCVJHQmvsanfZ69PEX96Gy4Wo24cbr3CneqJYMnoPmDk1u0lMLF3++AH71Vd9R7pCN1V9XiAmK6GKb4=@lists.php.net X-Gm-Message-State: AOJu0YyyEmNOVBu1x/NcHABnJITvwvQ8uTvcSVju1rs9kTjzgCWhDqyJ u2id/5oOa86GPKuXHjaoX0PyUZx82Q2HA2zYJnuqkdAGaJYJMdwyY66X0WReUqzrdhwFIgvBAzp pORIBhjRhtVMNVb8mMGNYwS/j4uoZUXKV X-Gm-Gg: ASbGncthboQJZLDcqrZOE0dIYVQlhC/UstWXFItWR6rYaIaFNZBTSQ7cGSOlFQ7P0wf gsNlN4bx9sZ3QnVsraPqH7duMCQCBpFJcNc0= X-Google-Smtp-Source: AGHT+IE5NV1i/NLVaK9IHYBKME9R6LZrUlTM4m9AtjBqDceGzFCeikn+id1jbV5lvDdTD256W4vZwPr2CN1WOoTHlLs= X-Received: by 2002:a05:6871:a4c4:b0:29d:caa2:f0ef with SMTP id 586e51a60fabf-2a7fcab92aemr19539390fac.6.1735585025131; Mon, 30 Dec 2024 10:57:05 -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> <209D4AA4-99BD-4861-B1A4-1BEB80DD3CF2@cmpct.info> In-Reply-To: <209D4AA4-99BD-4861-B1A4-1BEB80DD3CF2@cmpct.info> Date: Mon, 30 Dec 2024 19:56:53 +0100 Message-ID: Subject: Re: [PHP-DEV] Discussion: Remove file statcache? To: Calvin Buckley Cc: =?UTF-8?Q?K=C3=A9vin_Dunglas?= , Larry Garfield , php internals Content-Type: multipart/alternative; boundary="000000000000e69100062a8160c5" From: bukka@php.net (Jakub Zelenka) --000000000000e69100062a8160c5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Dec 22, 2024 at 4:55=E2=80=AFPM Calvin Buckley = wrote: > On Dec 22, 2024, at 10:57=E2=80=AFAM, K=C3=A9vin Dunglas wrote: > > > > On Sun, Dec 22, 2024 at 10:44=E2=80=AFAM Jakub Zelenka = wrote: > > Thinking about it, there might be a possibility to address it (at least > on Linux) using fanotify. Not sure about other platforms but maybe there > are some solutions to address it. Also it might get a bit complex and not > sure how much the solution is viable. > > > > For FrankenPHP, we successfully use https://github.com/e-dant/watcher > for this kind of usage. It supports Linux (fanotify, notify, epoll...), > macOS, and Windows, and is very efficient. > > It's a C++ library but with pure C bindings. > > > > Best, > > I think watching files makes sense for FrankenPHP's use case of > development server, but I can't imagine the overhead and > non-portability makes sense for the stat cache. I feel any gains you'd > have from stat cache would be offset by that. And it'd be unfortunately > the only way to actually solve the "external thing changes thing behind > the stat cache's back" problem. Yeah I did some investigation and was thinking more about this. To make it effective, we would need a new thread that would poll the selected API and then clear the stat cache file (there would need to be a write lock for this ofc). We have actually another use case for this worker thread on ZTS MacOS in relation of timers which we were discussing some time ago - it could open path to removing the need for signals (e.g. possibly getting step closer to using goroutines for FrankenPHP). This was just for ZTS and we realised that for that we need a better event loop. We have got some plans for that but it might take some time to get there. But there is some possibility that we could eventually have it. It could also mean that we could extend that stat cache for more than the last file which could have some positive impact on perf. What we could do in the meantime is to do more aggressive flushing as mentioned in https://bugs.php.net/bug.php?id=3D72666 (comments). That could be potentially also applied as a bug fix (or at least some part of it and the more aggressive parts in master). It won't fix it completely but it might help with the most problematic issues. Regards Jakub --000000000000e69100062a8160c5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, Dec 22, 2024 at 4:55=E2=80=AFPM C= alvin Buckley <calvin@cmpct.info> wrote:
On Dec 22, 2024, at 10:57=E2=80= =AFAM, K=C3=A9vin Dunglas <kevin@dunglas.fr> wrote:
>
> On Sun, Dec 22, 2024 at 10:44=E2=80=AFAM Jakub Zelenka <bukka@php.net> wrote:
> Thinking about it, there might be a possibility to address it (at leas= t on Linux) using fanotify. Not sure about other platforms but maybe there = are some solutions to address it. Also it might get a bit complex and not s= ure how much the solution is viable.
>
> For FrankenPHP, we successfully use https://github.com/e-dant/= watcher for this kind of usage. It supports Linux (fanotify, notify, ep= oll...), macOS, and Windows, and is very efficient.
> It's a C++ library but with pure C bindings.
>
> Best,

I think watching files makes sense for FrankenPHP's use case of
development server, but I can't imagine the overhead and
non-portability makes sense for the stat cache. I feel any gains you'd<= br> have from stat cache would be offset by that. And it'd be unfortunately=
the only way to actually solve the "external thing changes thing behin= d
the stat cache's back" problem.

Ye= ah I did some investigation and was thinking more about this. To make it ef= fective, we would need a new thread that would poll the selected API and th= en clear the stat cache file (there would need to be a write lock for this = ofc). We have actually another use case for this worker thread on ZTS MacOS= in relation of timers which we were discussing some time ago - it could op= en path to removing the need for signals (e.g. possibly getting step closer= to using goroutines for FrankenPHP). This was just for ZTS and we realised= that for that we need a better event loop. We have got some plans for that= but it might take some time to get there. But there is some possibility th= at we could eventually have it. It could also mean that we could extend tha= t stat cache for more than the last file which could have some positive imp= act on perf.

What we could do in the meantime is t= o do more aggressive flushing as mentioned in=C2=A0https://bugs.php.net/bug.php?id=3D72666 (co= mments). That could be potentially also applied as a bug fix (or at least s= ome part of it and the more aggressive parts in master). It won't fix i= t completely but it might help with the most problematic issues.
=
Regards

Jakub
--000000000000e69100062a8160c5--