Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101646 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36482 invoked from network); 21 Jan 2018 12:04:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jan 2018 12:04:53 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.175 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.223.175 mail-io0-f175.google.com Received: from [209.85.223.175] ([209.85.223.175:46077] helo=mail-io0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/B0-28995-4E1846A5 for ; Sun, 21 Jan 2018 07:04:53 -0500 Received: by mail-io0-f175.google.com with SMTP id p188so6601057ioe.12 for ; Sun, 21 Jan 2018 04:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=sGqQD/P2TESZn7UKLab0HRii7pCS3qA8b3CTa+YQspY=; b=DIv2ZorJeEn6a/6m/geXoH95Sg9klIRavvpzPflcMT0rBxcR/lF9T1bl4T8Xlv0LAN hXRsi2fC3oPkDFdV8vE41aGc2nNVO0DuNpmj8QmwA+VyI1DFvcMaUNsMJ55+weHypjlM tlq8tBgpeoZilCCrCdY9tuAkgh5hOuaB4a4EtAtSbTTvCFH38SWFWsSY/THHYEw2wJdj q6gRrYXrCqGQ7VA4JKKYR8nFaB7ATt3t8YQluE7zOncVUfxM9Dhpf7U9s4D4qgjOpxmK QTCGPAy5uhIE3yulJP4szTTt1sJrPcy1AXwh186dfdXftMQ+56KWxyP6E/VwTX000JT7 BVhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=sGqQD/P2TESZn7UKLab0HRii7pCS3qA8b3CTa+YQspY=; b=pMmHlTopQxB7GqyVnThXi/F2MXPCGiL1/anwLt/WRL6a4cNWOm5puFKp6OFeW11pR+ v16XIe3ltffSrOZFVhvr1lJoR/QDoSpFzT0vOaC0hFHSM6r6/ZsDhp8Lp0KBku2H1He1 gCHB7FB+lcftAGC0lbplpw8jutG+eEuufYeSMIHnpoMbZtR+Ly/yH9f2iDL5icKzSJTX +D8QXRFWFA0dwmRxmEI7cJOziJ/0sW+Qp9JdJ4n+mMl9B+cUz3O2sVeBGOnZOrS44BHa iVsY0PWIiKbPPRKf34JmXTMt0QT+6Ob8E0tcbvKwf2VMUTZfOBZrbyYEunOGQZqhZdjR /iKQ== X-Gm-Message-State: AKwxytdhDR/JYBghIWnhGzcqaH7aZDJcQwTuvmWsMUb/Hpe655KrombA U5LjUR27Pjz6i8LW1pE453HNZz0rBPbhtMRVpyY= X-Google-Smtp-Source: AH8x227LYD5xJFMxv5z9qrjEOZJ4uXJaH7E8Ge12dR1hJzpbOElBQFBhuAPrjhr2ERO1mQPXM8BX+ue9ROYGT62jMfw= X-Received: by 10.107.169.211 with SMTP id f80mr555102ioj.275.1516536289788; Sun, 21 Jan 2018 04:04:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.29.9 with HTTP; Sun, 21 Jan 2018 04:04:49 -0800 (PST) In-Reply-To: References: Date: Sun, 21 Jan 2018 13:04:49 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="001a11425c92d787da0563481eb1" Subject: Re: [PHP-DEV] OPCache: invalidate vs unlink From: nikita.ppv@gmail.com (Nikita Popov) --001a11425c92d787da0563481eb1 Content-Type: text/plain; charset="UTF-8" On Sun, Jan 21, 2018 at 11:00 AM, Fleshgrinder wrote: > `zend_accel_invalidate` is exposed to userland as `opcache_invalidate` > and marks a script as wasted, however, it does not remove that script > from the OPCache. > > There is also the `zend_accel_hash_unlink` that actually does that, it's > there since the beginning of time but without a single call to it in the > entire codebase. It actually removes a script from OPCache, yielding the > desired result of freeing up some space without requiring a complete > restart of OPCache. > > What are the reasons that this function is not used and not exposed? > What side-effects does it have if we actually selectively remove scripts > from OPCache? > > We replaced the `zend_accel_invalidate` call with > `zend_accel_hash_unlink` in the `opcache_invalidate` implementation and > it worked flawlessly. However, it could be that there are some things > that we are simply overlooking. > Unless you are running specifically into the max files limit (and not the memory limit), unlinking from the hashtable will not provide any benefit. It does exactly what it says on the tin, and in particular it's not going to free up any space. The reason why opcache has a restart mechanism, is that it does not track which files are currently (potentially) in use. During a restart it waits until all workers stop using SHM, at which point the memory can be safely reset. To improve this some more precise tracking of SHM usage would be necessary (not necessarily per-file, but more than just "yes or no"). Nikita --001a11425c92d787da0563481eb1--