Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98643 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29533 invoked from network); 27 Mar 2017 20:58:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Mar 2017 20:58:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=dz@heroku.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dz@heroku.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain heroku.com designates 209.85.128.171 as permitted sender) X-PHP-List-Original-Sender: dz@heroku.com X-Host-Fingerprint: 209.85.128.171 mail-wr0-f171.google.com Received: from [209.85.128.171] ([209.85.128.171:34893] helo=mail-wr0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B0/57-33481-50D79D85 for ; Mon, 27 Mar 2017 15:58:47 -0500 Received: by mail-wr0-f171.google.com with SMTP id u1so75494124wra.2 for ; Mon, 27 Mar 2017 13:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heroku.com; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=RY8MltL/TcM6dIzD0IxHLDy1aK5BKRCHuBwHlhkWaUo=; b=MsH9sO3s9C1Doy4OK29S9+yWQFQ1T7NOK34CJMmRtK4I3ysO2wUd8gpM3W1mfi7dkE C+QAYmDOPNlw9PXQRLmccUJSgiX5H04TMMyDmSAWXbDQB+rA5HWLtnBktQ3kRyrZ/IPA bMtGD3usCwgpGQ74goRvxxGMTMKbmZ60vYoLMmSxn4PkaBe0F9czaZ7N6NXHR9q2Zx4e 63wnSHhykOXz/4jF2asnnFY3VRde8V7n0R8vFxM24fnkLUgJOu2bKU/CMdVMMrxHuUCr ERl85WRX3CfjdLpPmGfigmM/JNtecAL5zrJa2X6U5opb647lH3MF7I5Pw6+UqPwTXloL l9xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=RY8MltL/TcM6dIzD0IxHLDy1aK5BKRCHuBwHlhkWaUo=; b=l+kY9G7DFQUGXZFdZ8lFDtflOULx8EHRe1qTp/GqhANUEZH9Qdp8DVK9he3pT7k0yV wWHM3tpeh+041U/3/00uXZEF3LoRqzjvV1CpcWNINlhgO1jOHEMaK7yDFIL1Cvst+6uj 0Yn+Et/KaUf9a0XXNqVqF36yrNZQGEDSgXVvySu68JBYDTmKDhgGi+Y6bZBpQyK5I40s chR2ndIDAHUiO/fMp0nrwllIiYZdz6W49px/0dj0FmlYxpaLABrOaFAUZuY8RNlTnSVs jy91R4irwgPsJ7TdLeCMqP+t2TtHb02Wm8NAeSK8B4XQF/RB99qNc910qMzJmY6XnlAN A0FQ== X-Gm-Message-State: AFeK/H3BH6Ez3IQdxIkWpeD9b8dwQNyNZiBWwRhGDD9FQ0P0VIUl9wOnSBhoSH+LWO8K6/Fk X-Received: by 10.28.137.211 with SMTP id l202mr11394712wmd.118.1490648322219; Mon, 27 Mar 2017 13:58:42 -0700 (PDT) Received: from [192.168.19.25] (ipbcc2189a.dynamic.kabel-deutschland.de. [188.194.24.154]) by smtp.gmail.com with ESMTPSA id o26sm887229wmi.18.2017.03.27.13.58.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 13:58:41 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) In-Reply-To: Date: Mon, 27 Mar 2017 22:58:40 +0200 Cc: ab@php.net, Ferenc Kovacs , Nikita Popov Content-Transfer-Encoding: quoted-printable Message-ID: References: <5BF394D3-919E-4140-AFF9-F46223AB49C4@heroku.com> To: PHP internals list X-Mailer: Apple Mail (2.3273) Subject: Re: [PHP-DEV] OPcache compilation performance regression in PHP 5.6/7 with huge classes From: dz@heroku.com (David Zuelke) Just another poke to surface it, in case this should be merged into the = 7.0 branch as well :) https://bugs.php.net/bug.php?id=3D74250 > On 19. Mar 2017, at 23:39, David Zuelke wrote: >=20 > Thanks for the fixes, Nikita! >=20 > Will they be merged to the PHP-7.0 branch as well? >=20 >=20 >> On 14 Mar 2017, at 16:39, Nikita Popov wrote: >>=20 >> On Tue, Mar 14, 2017 at 11:29 AM, David Zuelke wrote: >> Hi all, >>=20 >> There appears to be a performance regression in the CFG and DFA based = optimization passes of OPcache in PHP 5.6+ when loading huge classes = (such as those generated by Symfony's routing component) for the first = time. >>=20 >> The issue does not occur on PHP 5.5. Tests below are with 5.6.30, = 7.0.16 and 7.1.2 and default INI settings; I replicated the issue on = both macOS and Linux. >>=20 >> Test file here (it's from an actual application, slightly anonymized, = not a synthetic example): = https://gist.github.com/dzuelke/fe867f55f09e0bf79ecefcc815b7fe92 >>=20 >> Without OPcache, everything is fine in all versions: >>=20 >> $ time -p php -dopcache.enable_cli=3D0 hugeclass.php >> real 0.10 >> user 0.09 >> sys 0.00 >>=20 >> With OPcache on, things are suddenly much, much slower: >>=20 >> 5.6: >>=20 >> $ time -p php -dopcache.enable_cli=3D1 hugeclass.php >> real 3.23 >> user 3.21 >> sys 0.02 >>=20 >> 7.0: >>=20 >> $ time -p php -dopcache.enable_cli=3D1 hugeclass.php >> real 1.76 >> user 1.73 >> sys 0.02 >>=20 >> 7.1: >>=20 >> $ time -p php -dopcache.enable_cli=3D1 hugeclass.php >> real 4.01 >> user 3.98 >> sys 0.02 >>=20 >> For comparison, 5.5 is as speedy as you'd expect it to be: >>=20 >> $ time -p php -dopcache.enable_cli=3D1 hugeclass.php >> real 0.14 >> user 0.11 >> sys 0.02 >>=20 >> If we switch off optimization passes 5 (CFG based) and 6 (DFA based, = only in 7.1), everything is great again in all versions: >>=20 >> $ time -p php -dopcache.enable_cli=3D1 = -dopcache.optimization_level=3D0x7FFFFFCF hugeclass.php >> real 0.13 >> user 0.10 >> sys 0.02 >>=20 >> For 5.6 and 7.0, pass 6 is not a thing, but in 7.1, we can inspect = passes 5 and 6 separately. >>=20 >> Pass 5 (CFG based) already makes for a drastic performance hit in = 7.1: >>=20 >> $ time -p php -dopcache.enable_cli=3D1 = -dopcache.optimization_level=3D0x7FFFFFDF hugeclass.php >> real 0.88 >> user 0.86 >> sys 0.01 >>=20 >> But pass 6 (DFA based) is the one that causes the biggest slowdown in = 7.1: >>=20 >> $ time -p php -dopcache.enable_cli=3D1 = -dopcache.optimization_level=3D0x7FFFFFEF hugeclass.php >> real 3.29 >> user 3.24 >> sys 0.04 >>=20 >> In all versions, subsequent loads from the cache (such as when = running FPM or the built-in web server) are fast. >>=20 >> Is this slowness with a cold cache expected/accepted, or does that = qualify as a bug? >>=20 >> Yes, this is a bug. Optimization should never be this slow. >>=20 >> =46rom a quick perf run, the problem in the DFA pass is that TI is = quadratic in the number of calls (as call lookup is implemented as a = linear scan). This can be fixed with a more efficient map lookup. >> The problem in the CFG pass is that a large buffer is zeroed = repeatedly. >>=20 >> Nikita >=20