Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70458 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97643 invoked from network); 30 Nov 2013 21:31:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Nov 2013 21:31:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.75 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.75 smtp75.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.75] ([108.166.43.75:36645] helo=smtp75.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 22/E3-03478-B495A925 for ; Sat, 30 Nov 2013 16:31:56 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id B1E421E81EA; Sat, 30 Nov 2013 16:31:52 -0500 (EST) X-Virus-Scanned: OK Received: by smtp2.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 565ED1E81ED; Sat, 30 Nov 2013 16:31:52 -0500 (EST) Message-ID: <529A5947.5060701@sugarcrm.com> Date: Sat, 30 Nov 2013 13:31:51 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: Terry Ellison , PHP Internals References: <528CE64A.1020303@gmail.com> <528EA006.2090400@gmail.com> <52993190.4010905@gmail.com> <52995F97.7000901@sugarcrm.com> <5299B124.3030809@gmail.com> In-Reply-To: <5299B124.3030809@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Comments on non-unique naming convention for closures From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > The mangled zend_function entry is never executed; only used as a copy > template. I see. That makes it better, but not completely, please see below. > This is really a separate thread, but in order to allow opcode caching, > the PHP compiler *must* generate the same oparray for a given source > sequence, so in fact even if the same function (...) {...} text sequence > occured multiple times in the same source file, then the oparrays would > be identical anyway, and using the same mangled zend_function entry is > fine. However, if the 1/2^64 (or thereabouts) chance of a false This is true. However, if multiple scripts have the same function name, and are added to the cache separately in different time, by default the engine does not allow adding the same function twice (even if it has the same op-array). We could code around it but why create problems for ourselves if we could easily avoid it? So I think it would be better to add something to the mix - like filename/lineno or counter - to ensure it is not the same. I'm not worried about the hash collisions, but copy-paste happens much more frequent than 1/2^64 hash collision. > collision is unacceptable, we could always embed the closure compile > count in the name as well, or the microsecond compile time. I would avoid using time, as getting time is usually a system call and system calls are slow. Counter or filename/lineno or anything that makes the hash different would be fine. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227