Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92475 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97236 invoked from network); 19 Apr 2016 16:54:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Apr 2016 16:54:07 -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.192.41 as permitted sender) X-PHP-List-Original-Sender: dz@heroku.com X-Host-Fingerprint: 209.85.192.41 mail-qg0-f41.google.com Received: from [209.85.192.41] ([209.85.192.41:36833] helo=mail-qg0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B4/61-22821-DA266175 for ; Tue, 19 Apr 2016 12:54:06 -0400 Received: by mail-qg0-f41.google.com with SMTP id f52so12528353qga.3 for ; Tue, 19 Apr 2016 09:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heroku-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=707CrEgWKvHfxwX2nfgYlOkYoVE6Yi3nMhT1DU7TfPk=; b=w4S5yGdpf43Rz6Irogvd/f4xdq5vZc3GTqmOazRilsMAqxtBFxuPE0UrwoixjqAMGy PapiLsgCykITl3FdCqrGG4g+muFgMZfoxc6FpOUc7R4hwYSHaB0WG2OmIPUoXoKkbGE5 DWshjkK+LsL3IEQ7kq8Oq30y0svU386Bgmfvap6PEshN001PSD6eqGFP3Q/9itifdZSQ Yc82sYNAzb6up3Bwj4SJ6LOTt+jJzxqfH5BpfRaAEO2VUitsZe/h2BPo1YUFbAUR45eC QVcLvI2p8Y7Ysy6yxg9wxE5KQngC5MYfu1EJAp7dqkw16obAXWp2kwIe7UmzbE0WpYw3 FPAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=707CrEgWKvHfxwX2nfgYlOkYoVE6Yi3nMhT1DU7TfPk=; b=JoBa5ohmevfeHF8lbSMpN0Ql7MA1svc6+zm8l8yLlRzDx70Myft0XQx/B6dRQLSnTK sKKssrxtj0qvpbxeJVqbxmqpai8Nwv6h0JrLN1SCKWabxcCfXicswoBQ0Bz9FPEa4bSy IiRgeD81aA09YmbK+Lhs6KyMaBe1B45SlW/UngFPVfjZiQkjxKt4o/P7VmttQ6H/S5mo 89oyfM0LSBA4prec2Rm4UY69s2xaiSmcyz/VImSa1mmC8FgE0V8Thcz+NbwsxMTEGpbr W6hEbFCneoeMUSRMQAQ0vdvFQd6N+mE+ldONKpQiFkrxSgUsA6h2oaJmkwDz9i4PzjA9 qAZw== X-Gm-Message-State: AOPr4FX3sK/EBKxIUWfL7A4Sd8qpuS6VnZLqHjbO33YqaJuKPL+asqM293V3L4ltfl5+pDFR X-Received: by 10.140.30.247 with SMTP id d110mr4877600qgd.43.1461084842403; Tue, 19 Apr 2016 09:54:02 -0700 (PDT) Received: from [10.0.1.5] (cpe-68-175-101-104.nyc.res.rr.com. [68.175.101.104]) by smtp.gmail.com with ESMTPSA id 71sm5242734qgh.9.2016.04.19.09.54.01 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Apr 2016 09:54:01 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) In-Reply-To: Date: Tue, 19 Apr 2016 18:54:00 +0200 Cc: "internals@lists.php.net" Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Lin Yo-An X-Mailer: Apple Mail (2.3124) Subject: Re: [PHP-DEV] Proposal: Startup snapshot for optimizing app load time From: dz@heroku.com (David Zuelke) I think this solution is merely a band-aid for a more profound = architectural weakness of current PHP setups, where a web server call = out to the engine (via embedding or FastCGI) to execute a script, which = causes this recurring initialization overhead in the first place. The future is (or should be) servers implemented fully in PHP code (e.g. = PHP-PM), just like every other comparable language (Ruby, Python, Java, = ...) already does. That also brings many other benefits, such as the = ability to handle upgrades to WebSockets in the same codebase, stream = request bodies as they're being uploaded, and so forth. And the performance figures that PHP-PM delivers with Symfony validate = that approach IMO. > On 13.04.2016, at 17:55, Lin Yo-An wrote: >=20 > Hi internals, >=20 >=20 > The javascript engine V8 uses a strategy called "startup snapshot" to > optimize app load time (see > http://v8project.blogspot.tw/2015/09/custom-startup-snapshots.html for = more > details) >=20 > The approach used by V8 creates a snapshot from heap, so the V8Context > could be reused directly without re-running the bootstraping code. >=20 > I think running javascript app in the browser is somehow like we run = php > script for each requests where the app bootstrapping code is required = to be > executed repeatedly for each request. >=20 > Currently, our opcache extension can cache the byte codes, but the = byte > codes still need to be executed every time when bootstrapping an app, = and > which increases the overhead for each request. >=20 > For example, a lot of applications use composer to initialize the = class > loader via the statement below: >=20 > require "vendor/autoload.php"; >=20 > The statement above produces thousands of byte code to run, which is = to > make an app ready. (If you use vld extension to show the opcodes) >=20 > However, if we can support a simple syntax to describe what is doing > "bootstrap", we are able to create a startup snapshot from it. >=20 >=20 > The proposal here want to introduce some new syntax to optimize app = load > time though the below syntax: >=20 > bootstrap "vendor/autoload.php"; // caches the context after = running > this script. >=20 > Or >=20 > bootstrap { > require "vendor/autoload.php"; > // do something else for making app ready > }; >=20 > And of course, we might detect the bootstrap script automatically = without > creating new syntax and opcodes, but I think it's hard to do because = PHP > applications can be written by many ways... >=20 >=20 > Questions > =3D=3D=3D=3D=3D=3D=3D=3D >=20 > I don't know if this approach is doable or not. Or maybe we can = support > this in a separated extension instead of changing the zend core? >=20 > Do you guys think it's doable? would you like to share your idea for = this? >=20 >=20 >=20 >=20 >=20 >=20 > Best Regards, >=20 > Yo-An Lin