Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85442 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13013 invoked from network); 24 Mar 2015 10:30:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Mar 2015 10:30:34 -0000 Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-la0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:33673] helo=mail-la0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 99/00-12194-8CC31155 for ; Tue, 24 Mar 2015 05:30:32 -0500 Received: by labto5 with SMTP id to5so47994213lab.0 for ; Tue, 24 Mar 2015 03:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=V7qxAS1iJH+IVEyTAP0Q4B2TGH/dZE2ROo6zCSVRNJ4=; b=XxFS+83F0H4zO6+wzHvjpaqrmHYI6bL9kkr4dNZbLqpxoXz/99bpHeZCFXjR2dQImj sl1m1DzUDpBPAc1UZjkmLIoDSCxeWFh3KN58Dxfkf+oSPRhSLVptvjQfZLGsILDGb5j1 xTKjB85sbEbp/evS5MthZ1oL1tctnO4VBZ0lJODsPAzfVWZmsiuSK4qgcN48wuNbs1k+ hqD+Q83h/d6+dhXzfsuTpyWXjb/fGrGuGot6QjhlCRw4ibrbIPnlKAl2ghEYyMgmJpFX VjkN/xb31RmI3ebuBACL0MGQFQLSHKhzgrN9zNeaLJyn1sAroh51JjPC/fNKeWEin81I EQ5A== X-Received: by 10.152.36.193 with SMTP id s1mr3108312laj.17.1427193029266; Tue, 24 Mar 2015 03:30:29 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.114.203.39 with HTTP; Tue, 24 Mar 2015 03:30:08 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 Mar 2015 18:30:08 +0800 X-Google-Sender-Auth: ms6HnoOLuO29dH36evzZErz5oIc Message-ID: To: Nikita Popov Cc: Dmitry Stogov , Xinchen Hui , Joe Watkins , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: Use "ropes" for string concatenation From: xinchen.h@zend.com (Xinchen Hui) Hey: On Tue, Mar 24, 2015 at 5:28 PM, Xinchen Hui wrote: > Hey > > Sent from my iPhone > > On Mar 24, 2015, at 5: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. > > then we can implement is in rope_end handler, and don't convert op to string > in rope add var handler. Never mind, lets stict to the first banch instead. thanks for reviewing, :) thanks > > Thanks > > Nikita -- Xinchen Hui @Laruence http://www.laruence.com/