Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91785 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85006 invoked from network); 20 Mar 2016 08:52:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2016 08:52:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.176 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 209.85.217.176 mail-lb0-f176.google.com Received: from [209.85.217.176] ([209.85.217.176:34826] helo=mail-lb0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AF/83-48999-FA46EE65 for ; Sun, 20 Mar 2016 03:52:00 -0500 Received: by mail-lb0-f176.google.com with SMTP id bc4so111181945lbc.2 for ; Sun, 20 Mar 2016 01:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:subject:references:date:mime-version:content-transfer-encoding :from:message-id:in-reply-to:user-agent; bh=1xdAxXiUJr+gBX0rkygq8THYUlRHRZjZT3rOKFTHYv0=; b=HfkHZHqtoznvFLKSvudrd13ewHMHBRUsTM5BJBw4DeZ235k5AweKSFk3igpTnxILOD emHZ8XZar5nSXdALexWMNwR4pVoRaFvSRb+lAA3efSMqauvIjf7klwvqc6/GUSPJKbug cxZBmalN2yzbEojjU8wzWiksMmetRHLlO7JBcU4I8va9IgHm4C04W6Fwd/xyeyuXhSm5 sj0j1Yr7wUo2RMIzVm6el0hUq36DesLCbc+57SUU/Jkj/naA9P0Ga7X3/hvQRJnaSMic J3yn6KooKOrJzxc31chh2KM6eIwpiZKhOqY+MVsqKGe1/6hgURu4JweTanJlYXVXCQ5B sz0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=1xdAxXiUJr+gBX0rkygq8THYUlRHRZjZT3rOKFTHYv0=; b=k7+zP5DTPNuUB6PfZ8oRzYtlJLFumEaUeqwGFbLb/p7E410H2NBy0kOVMdt22NTMGQ KwV+KmHdTo0DFBnzZs7L9/+NGC1Bemgghn+RUTk5Pxy8lyxPXlypSZrrXGNweVe8Trq2 y33I8HTNDFCFdbcU4glSObepIoaOO/2Jw2F85JrUxZuCsrKwPwuaWWPSlOn1pHDeZMc4 cqx5e5xKaY5ReVNJATxFXizzPH9UPTgb4cFye5nWJ3S/ldGndOhfj9uZOkYrj9MzmrT+ Y6bAJph5onk0sy6tbBnyg3DA32gKP29WnsyMTynP0w2XC1raGM85KGmI3WxWUt/nDSIc fbPw== X-Gm-Message-State: AD7BkJLJO7z+DgXWhGBBnTyeNLU2nSp2TudlORZrw7kK1Pfo7Emv1iEpFdXNP6rG5HdFlQ== X-Received: by 10.112.161.198 with SMTP id xu6mr8633134lbb.131.1458463917005; Sun, 20 Mar 2016 01:51:57 -0700 (PDT) Received: from nikita-pc ([89.250.5.98]) by smtp.gmail.com with ESMTPSA id t2sm1945953lbr.45.2016.03.20.01.51.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 20 Mar 2016 01:51:56 -0700 (PDT) Content-Type: text/plain; charset=koi8-r; format=flowed; delsp=yes To: internals@lists.php.net References: <44.0B.03097.E29BDE65@pb1.pair.com> Date: Sun, 20 Mar 2016 11:52:05 +0300 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: <44.0B.03097.E29BDE65@pb1.pair.com> User-Agent: Opera Mail/12.17 (Win32) Subject: Re: [PHP-DEV] Object getter method optimization From: inefedor@gmail.com ("Nikita Nefedov") On Sat, 19 Mar 2016 23:40:09 +0300, Andrea Faulds wrote: > Hi Lin, > > Lin Yo-An wrote: >> Since the original approach doesn't work, here comes another new idea: >> >> When executing method call on an object, if we found the method body are >> just 2 op codes (FETCH_OBJ_R and RETURN), we then denote the method is a >> "getter method" >> >> And the next time, when we execute the same method, we found the "getter >> method" flag, we simply execute FETCH_OBJ_R on that object and return >> the >> value to avoid extra op code execution time. >> >> Do you think if this could work? > > For a while I'd also been wondering if we could implement some > implementation along these lines. Another approach could be possibly > replacing such methods with an C implementation (though I don't know if > non-internal classes can have internal methods). > > I don't know how successful it will be, but I'm interested to hear how > much improvement it gives if you get it working. > > Thanks! I was playing with this idea sometime ago, it gives good performance boost for code like `for ($i = 0; $i < 100000; $i++) $a->getFoo();` but in the end of the day it's a very limited optimization. If you abstract away from getters and say you want to optimize more and more small functions like this one, you end up realizing that what you're actually doing is what JIT compilation would do in a more generic way.