Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85440 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5707 invoked from network); 24 Mar 2015 09:28:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Mar 2015 09:28:37 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.49 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.192.49 mail-qg0-f49.google.com Received: from [209.85.192.49] ([209.85.192.49:35907] helo=mail-qg0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/02-25887-54E21155 for ; Tue, 24 Mar 2015 04:28:37 -0500 Received: by qgez102 with SMTP id z102so97517431qge.3 for ; Tue, 24 Mar 2015 02:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=YP0/DB7HpQVTmtfJV6cs0XkZhbZUcqcfMbw1olO+fyA=; b=ruIVTKeq6RP9Fla8+KBePr7hbPR8WgO7FIYmyHF6nWQraICrxW4hjfoph8eQt65Frr xXsqGyTXg0qdTK5Q2Dz7DupbC+8EOSTBvfa7UXLDWc7C19zhlB1iEbXJEtDm0mdwWKIS KNshZDtmdckyKBWSubwl/oY0aDwTOnrpcte/tqa+ubMEg8liliffsXJJkyCqlpiU6RDL 6yKwykVXfAhS53HBxJuaKss7GaibDtlp+lBB4d2KTS3kevfPP55ooWmgq0zm9xEqwCEU 4qXAccwowxzvYf4JJC2i0umWI40jsXbCG0YyZ4811mF7G8RFxDDhDjB0fU4vG250MA/9 MzCA== MIME-Version: 1.0 X-Received: by 10.229.246.201 with SMTP id lz9mr4608264qcb.14.1427189313802; Tue, 24 Mar 2015 02:28:33 -0700 (PDT) Received: by 10.96.39.195 with HTTP; Tue, 24 Mar 2015 02:28:33 -0700 (PDT) Received: by 10.96.39.195 with HTTP; Tue, 24 Mar 2015 02:28:33 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 Mar 2015 16:28:33 +0700 Message-ID: To: Nikita Popov Cc: Joe Watkins , PHP internals , Dmitry Stogov , Xinchen Hui Content-Type: multipart/alternative; boundary=001a11c3bde81397a20512056803 Subject: Re: [PHP-DEV] Re: Use "ropes" for string concatenation From: pierre.php@gmail.com (Pierre Joye) --001a11c3bde81397a20512056803 Content-Type: text/plain; charset=UTF-8 On Mar 24, 2015 4:11 PM, "Nikita Popov" wrote: > > On Mon, Mar 23, 2015 at 11:41 PM, Dmitry Stogov wrote: > > > Hi, > > > > Recently, Xinchen and me worked on optimization that eliminates useless > > reallocations and copying during string concatenation (ZEND_ADD_STRING and > > family + ZEND_CONCAT). > > > > The idea comes from ropes, but adopted especially for our needs. > > Rope is popular data structure in languages with immutable strings. > > http://en.wikipedia.org/wiki/Rope_%28data_structure%29 > > > > We don't try to use ropes everywhere in the engine (at least it's too > > later for 7.0), only for concatenation. > > > > The first branch uses ropes only instead of ZEND_ADD_STRING and family. > > This must be safe. The only problem is possible memory leaks on exception > > (but we already have this problem anyway). The simplest way to understand > > the patch - read code for new opcodes in zend_vm_def.h. > > > > https://github.com/php/php-src/pull/1194/files > > > > The second branch in addition uses ropes for series of ZEND_CONCAT. It > > disables calls to do_operation(ZEND_CONCAT) handler of custom internal > > classes. > > > > https://github.com/php/php-src/pull/1195/files > > > > Both make slight speed improvement (first +0.3%, second +0.6% on wordpress > > home page). > > > > We don't currently use ability to override CONCAT behavior in internal > > classes, and I'm not sure if it may be useful at all. (For example Lua > > doesn't provide concat meta-method). May be remove it? > > > > Overloading concat operator will be useful in the future for the > implementation of the UString class, for example. Indeed :) Which will be 7.1, at best, no matter which one. Hence a bit my thoughts about waiting a bit and spend more time on that, if other ops make sense too. But again, if everyone agrees, no issue to get that part in already. --001a11c3bde81397a20512056803--