Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85261 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8354 invoked from network); 20 Mar 2015 02:33:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2015 02:33:17 -0000 Authentication-Results: pb1.pair.com header.from=danack@basereality.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=danack@basereality.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain basereality.com from 209.85.213.44 cause and error) X-PHP-List-Original-Sender: danack@basereality.com X-Host-Fingerprint: 209.85.213.44 mail-yh0-f44.google.com Received: from [209.85.213.44] ([209.85.213.44:35163] helo=mail-yh0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/F5-25408-BE68B055 for ; Thu, 19 Mar 2015 21:33:16 -0500 Received: by yhim52 with SMTP id m52so5670032yhi.2 for ; Thu, 19 Mar 2015 19:33:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=HcoC2ZqqXdyPzyYqP1BZSamjKJxEHCu5id6rPf6mcWI=; b=dvNyr1nTW8C0Di6YfNdM8hMtemx1g0K47Fr9vVx5/9z/TcswZoLgmHG837TDaejT+l 51cDNMyFke1kIecQeXfVPmDJTPdBaC86LkPvUNn0DxxLDiW5dKrEkSwh4DsBnYOTojib 5QwujaKw4PNQuObbF8q8iAtz2lwoWTzc7Cb70YlxMOa3AZNi/CHTHRc4WAha9apbbcU5 FSu1OLQ9vBhqbfp8/iPuUoCGSNYlO3Pkyr2bFzoYOXuel4V8SGF3T0ec+wuo48mNGSZo c8M/9m7Jo6918MibAlFKPgRaRomcHDXzcvp/bv7WhMCfze6KLW+WTPN+2yJDXibsJRp5 3ygg== X-Gm-Message-State: ALoCoQnASlUAqJM12vyQ9QMyx/Ovt8RBUfddNTl0HStctxPPPDbGoetZqNgy5i3dZ5Ei6tAQ6xJU MIME-Version: 1.0 X-Received: by 10.236.38.162 with SMTP id a22mr79099634yhb.167.1426818792167; Thu, 19 Mar 2015 19:33:12 -0700 (PDT) Received: by 10.170.71.86 with HTTP; Thu, 19 Mar 2015 19:33:12 -0700 (PDT) X-Originating-IP: [2.99.229.112] In-Reply-To: References: Date: Fri, 20 Mar 2015 02:33:12 +0000 Message-ID: To: Eric Stenson Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [Q] Does PHP have a negative cache for file stat operations? From: danack@basereality.com (Dan Ackroyd) On 19 March 2015 at 20:26, Eric Stenson wrote: > PHP Internals folks-- > > We're doing some performance work in WinCache, and we're finding that some frameworks > are...uh...enthusiastically using file_exists(), is_file() and is_dir() functions on > files/directories that don't exist. Every. Single. Pageload. What context are these filesystem hits in, is it class autoloading by any chance? If so there was a function added to OPCache and a hopefully upcoming feature to Composer that may be of interest. http://php.net/manual/en/function.opcache-is-script-cached.php https://github.com/composer/composer/pull/3802 Those two combined eliminate a huge number of file_exists calls, similar to what you are describing. Though I guess the is_file and is_dir functions might be in a different area of code. > Does the PHP stat cache include negative cache entries? If not, why not? Negative caches tend to just be the wrong thing. A positive cache returns usable data, with the proviso that the data might be out of date. A negative cache, returns nothing usable. For example, a browser caching a page that returns a 200 response is fine, as it's caching some information that was acceptable. A browser caching a 50x error page would just be caching useless information. Another example - the Composer autoloader behaves as a negative cache, in that it caches the 'fact' that a class doesn't exist. This gets in the way of being able to dynamically generate code, as once you've called `class_exists("SomeAutogeneratedClass", true);` you can no longer use the registered autoloaders to load that class, and instead have to load it by hand. cheers Dan