Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:115930
Return-Path: <kevin@ie.suberic.net>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 22496 invoked from network); 3 Sep 2021 13:31:40 -0000
Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5)
  by pb1.pair.com with SMTP; 3 Sep 2021 13:31:40 -0000
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id 764911804AD
	for <internals@lists.php.net>; Fri,  3 Sep 2021 07:08:09 -0700 (PDT)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,
	RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,
	SPF_PASS autolearn=no autolearn_force=no version=3.4.2
X-Spam-ASN: AS15169 209.85.128.0/17
X-Spam-Virus: No
X-Envelope-From: <kevin@ie.suberic.net>
Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by php-smtp4.php.net (Postfix) with ESMTPS
	for <internals@lists.php.net>; Fri,  3 Sep 2021 07:08:09 -0700 (PDT)
Received: by mail-pg1-f177.google.com with SMTP id n18so5620181pgm.12
        for <internals@lists.php.net>; Fri, 03 Sep 2021 07:08:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=lyda.ie; s=google;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :cc;
        bh=4bG2nhkrYIMfC1qKoMF6v8G8iRN92LvSser26qJrTmQ=;
        b=OLwXdR/cJ2XoibMT2IQT6V43w9JClTdH+uHbfWnXw5gSamp/ys0DOJyryJF8Px+YeH
         465xBJYAVat7EgeYNmWfDp9taILq8GlZLGkKSagtoM43c4i4NPt0YHimUzNwdObEqtpv
         CQ3huG3p23NFgn+NOnw9eVkLakXjrlnBaIivdOEFHaD6R4oIzYB3iXx4Q7tx+4Rr2tqU
         qkDj7LEQZUTkV9lji91Q+ZCgBLnkv4cwsELgTjJWctItJWFL9upTWg10zTu6adIzCZOj
         fBv5pVhkIDGwh7Vqgm0f2nUIp4ivO45hOujj9MAoXYdGKT8+U18RmKrk/1KGcG+KJlN/
         885Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:cc;
        bh=4bG2nhkrYIMfC1qKoMF6v8G8iRN92LvSser26qJrTmQ=;
        b=c1awBm4jw1/+OiadHBlakxfH5U1WIYo/pp5a+zMWX/MLSXaWOA4xTHrtQ8rD7YgUUJ
         2Y9FHRCl8s6a7N0SxJXglFQ4uTaWg3gELiZ+8cclFtqHFD7kTOx3ymyMQvEKYCZsySGO
         uauEocbQ2f34ddUiPDsroX5hQtrKJKE+CljizrzfVgtgrhu/Feaow5jt54is3qmEFI9C
         jmXwzNIc6EYQi34JHHKg/0+ZDqMiDpSWzmK0ANWCIhJa6C+MR+053xL4iTT0V0jB9PcX
         zlwse/+whaQ2bLnpsJS+NIrn2xmOCsXEzCMC2jqDXfyc587N7d3cIm1mlbY0jyw2hAS6
         vHsQ==
X-Gm-Message-State: AOAM530XURoZ+q1IEyXMIJK6w1BLIFyiKQc29a4bbc/zguIxj299ltLF
	lCBhi992WIZUUdQMBMWgptBSUrHQ5xW21rcx2fBvWm0SbUp74w==
X-Google-Smtp-Source: ABdhPJxhBWCYjLfZqzmZbAB71rmjOuvJahTw9NETZAg8FoHtsEe0lFZu9h2NEfTBMMeeduD9EJWCWRfIaH0j6fycl1o=
X-Received: by 2002:a63:eb41:: with SMTP id b1mr3807055pgk.236.1630678087012;
 Fri, 03 Sep 2021 07:08:07 -0700 (PDT)
MIME-Version: 1.0
References: <CADJ56BRPi_GHE7R70k-NdgQ6ea2ogLSe6Z6Eg-YGKpeYSmvhbQ@mail.gmail.com>
 <CAJvSBVP2pCT6wDNrpVDp=1_JQtrG=H2Y2fy8L-vcvgawhWstCw@mail.gmail.com>
 <CADJ56BSHDTZ86oRqMHfsB860WXsO3ORv7JVGArJx+Q7FN4nD5g@mail.gmail.com> <0A048A30-444F-4DB0-A79C-9EA9BD07B1EC@cschneid.com>
In-Reply-To: <0A048A30-444F-4DB0-A79C-9EA9BD07B1EC@cschneid.com>
Date: Fri, 3 Sep 2021 15:07:56 +0100
Message-ID: <CADJ56BT=TDF2_fn5ci-=34cuMSeks5NzA4r5_5acVNum9PY_kw@mail.gmail.com>
To: Christian Schneider <cschneid@cschneid.com>
Cc: PHP internals <internals@lists.php.net>
Content-Type: text/plain; charset="UTF-8"
Subject: Re: [PHP-DEV] Adding a way to disable the stat cache
From: kevin@lyda.ie (Kevin Lyda)

On Fri, Sep 3, 2021 at 2:34 PM Christian Schneider
<cschneid@cschneid.com> wrote:
> If I remember correctly it was about reducing the number of system calls. Is this no issue any more?
> Has a quick benchmark been done to see the positive / negative impact of the stat cache for a typical application?

In the lifespan of php it really wasn't an issue unless someone was
doing something that wasn't wise - I can't think of a single reason to
stat a file in a tight loop.

However more importantly the current behaviour returns bad data for
perfectly correct programs. So for example on a unix box...

<?php
passthru('touch foo');
if (is_file('foo')) {
    echo "Correct\n";
}
passthru('rm foo');
if (is_file('foo')) {
    echo "Incorrect\n";
}
?>

Now this is a silly toy, but imagine using is_file to see if a
graphics file exists, running an image processing program on it to
modify it, and then using a stat call to get the file length to
populate the Content-Length field - it will almost certainly be wrong.

Personally I value correctness first and then performance is a
priority further down that list of attributes (security and
readability would also be higher priorities). However as the current
behaviour has existed for several decades, this change makes sure the
incorrect historical behaviour is the default.

Kevin