Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85264 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24420 invoked from network); 20 Mar 2015 06:13:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2015 06:13:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.54 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.54 mail-pa0-f54.google.com Received: from [209.85.220.54] ([209.85.220.54:34147] helo=mail-pa0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 04/C7-25408-C8ABB055 for ; Fri, 20 Mar 2015 01:13:32 -0500 Received: by pacwe9 with SMTP id we9so98984263pac.1 for ; Thu, 19 Mar 2015 23:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=qLZWVraQcT1UT6sKhW+n9Hb9SXcKxfQHN9pjpwWS/dA=; b=EE2oChguNhrVuPGIf+JYvE2mIw9DyfTqzLP9LoNLVOvs7Bvq4YWAdNuHaVtuzFhddv O1Smi8XGPZaqc0r1tVy0jPYOyDhf5fRQ6eGQRvfc8UbqifWqqoFYDX1DPF2uIqBgvufi jAurwWsDbFDlkV0EAMa/dNMkEjVFusZLApQE/RnRLYbhi/HAeb2CLpIMnlsLkKb9ZpaN YlhB78Gg8mvlw+k+R+rl7B8LKNHLnRCqIOMFBmMcNWeFu2/P8iwg5A4W4riGk7wtE37j C5HOSj9obUUapdm7Rt/kq+MoaM8fZcA+C+ksM3L5Ad63HyZ57pN9U+w6sCFfTRp7210k WJpw== X-Received: by 10.70.38.77 with SMTP id e13mr38563694pdk.160.1426832009166; Thu, 19 Mar 2015 23:13:29 -0700 (PDT) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id 5sm6087674pdg.45.2015.03.19.23.13.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Mar 2015 23:13:28 -0700 (PDT) Message-ID: <550BBA87.6070307@gmail.com> Date: Thu, 19 Mar 2015 23:13:27 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Eric Stenson , "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [Q] Does PHP have a negative cache for file stat operations? From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > 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. > > Does the PHP stat cache include negative cache entries? If not, why > not? Negative cache is tricky. Most frequent patterns look like this: 1. if(file_exists("blah")) { do stuff } 2. if(!file_exists("blah")) { throw new Exception("no blah!"); } do stuff 3. if(!file_exists("blah")) { create("blah"); } do stuff Caching negative even short term would subtly break case 3, in that it would force creation of the file every time, thus killing any benefit from any caching (usually file creation is much more expensive process). Long term caching would also be big trouble with case 2. Unless there's a way to reset the cache and the app is very careful to do it - but file can be created by external means and also case 2 would be harder to fix without losing the benefits of caching. So one may ask, why case 1 is not a problem? Usually it's because if the file is there, apps rarely delete them by themselves, or at least adding new files is much more frequent operation than deleting existing ones that are used by the app. -- Stas Malyshev smalyshev@gmail.com