Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92249 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4950 invoked from network); 13 Apr 2016 15:55:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Apr 2016 15:55:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=cornelius.howl@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cornelius.howl@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.46 as permitted sender) X-PHP-List-Original-Sender: cornelius.howl@gmail.com X-Host-Fingerprint: 209.85.218.46 mail-oi0-f46.google.com Received: from [209.85.218.46] ([209.85.218.46:35799] helo=mail-oi0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CE/91-26321-80C6E075 for ; Wed, 13 Apr 2016 11:55:52 -0400 Received: by mail-oi0-f46.google.com with SMTP id p188so68871282oih.2 for ; Wed, 13 Apr 2016 08:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=N0qEH0K2uTdlQPLzb3Ne9YE3uvH/E1dF6PmmvNOOpns=; b=X4Up6UoI8E88EsEAV96xw7FiC0U2KwXUctb8l3Gmq9yioEaCjm4e6Ap9mlC4gqm6vS mc5+/lFMLzdysJE1pOTISWCS+CaNS/eCFE6UaRE0YDVHPBsH4tnkH8i+RaOEuOLvw0wb hxFnvVqaTYVbZQRiqkv3qL8X1fSvZIsdreAkkW+qdWplvvsjLygMlVX8x1bEHEqdbZQX VzMtg2HPvJ9u48jQvhsQepW/GE+NtXtZQygGgZlaoR5ZcJusxMJiK54lYovFsnRVaL/Y Ha9+vU5CHYoXuUP98bV1cDBzoa1ECxA4fIEVj77JlM30wotMrSsGEdhVRLyU4GY2hYZj Hg7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=N0qEH0K2uTdlQPLzb3Ne9YE3uvH/E1dF6PmmvNOOpns=; b=XkW4GpYXDbfQ+n2oMiWjLKUjCwD/qalf2DKTtw3calxZaaK0ab1ajdL6tbeUz2goDi UeJ3DbuwV8Cfmh64Kwn8fyL8NOBd+8YganbzgBK72RWf/oHdHouTpRuorT0Cb0j36LEq BwlBIcJYrfBGMlVPNvlLqQjll1b9wImO7ukpcaIMy3aHykj5O22ZPt069c85wwo6BUAG 4cfjpqCQ5BBFNcy5duYRDH/9wBGC1P03552CxI2d0uVnyYPsJrwbYYDB1sHTbHRQZN/i IqZDidkTVfVCfrPxE0ATIqJxYo2OEDDX5bOrpVQsvniNIKV/dEgjGEIEVdkImD6/8vRK qZPg== X-Gm-Message-State: AOPr4FUTt7Q3Lh74kycVr3Cdu1Od9znpj9KS7kdFQ/moW8JXyeIvIHe8m8/nZFmnhhNdqdBLCo59XPC97Zpaqw== MIME-Version: 1.0 X-Received: by 10.157.5.106 with SMTP id 97mr4519207otw.127.1460562949286; Wed, 13 Apr 2016 08:55:49 -0700 (PDT) Received: by 10.157.7.194 with HTTP; Wed, 13 Apr 2016 08:55:49 -0700 (PDT) Date: Wed, 13 Apr 2016 23:55:49 +0800 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=94eb2c0479a4c3b4a105305fcfd0 Subject: Proposal: Startup snapshot for optimizing app load time From: cornelius.howl@gmail.com (Lin Yo-An) --94eb2c0479a4c3b4a105305fcfd0 Content-Type: text/plain; charset=UTF-8 Hi internals, 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) The approach used by V8 creates a snapshot from heap, so the V8Context could be reused directly without re-running the bootstraping code. 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. 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. For example, a lot of applications use composer to initialize the class loader via the statement below: require "vendor/autoload.php"; 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) However, if we can support a simple syntax to describe what is doing "bootstrap", we are able to create a startup snapshot from it. The proposal here want to introduce some new syntax to optimize app load time though the below syntax: bootstrap "vendor/autoload.php"; // caches the context after running this script. Or bootstrap { require "vendor/autoload.php"; // do something else for making app ready }; 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... Questions ======== 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? Do you guys think it's doable? would you like to share your idea for this? Best Regards, Yo-An Lin --94eb2c0479a4c3b4a105305fcfd0--