Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85439 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5496 invoked from network); 24 Mar 2015 09:28:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Mar 2015 09:28:30 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.160.182 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.160.182 mail-yk0-f182.google.com Received: from [209.85.160.182] ([209.85.160.182:32881] helo=mail-yk0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 90/02-25887-C3E21155 for ; Tue, 24 Mar 2015 04:28:28 -0500 Received: by ykek76 with SMTP id k76so86007724yke.0 for ; Tue, 24 Mar 2015 02:28:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=UvkA7CZ/t+QjwCQSmaXQnaVGo1YgSfO8F6f9xXWuWIg=; b=WIzlz3CID+30W/RDX9HDUcnjwveFXbtlOUyH4QRqOKSmUynujaoV5f0tJSHatFAxMB Njp7Gh1janbvGi70atOleJi2unszbtskXr1aZaEh9scBBRNy4xnFGtPMRU8yP7cWQnj4 HuIKB7HAxJShZh6s1BIbBwUZLniuIjTnJqQQtfT8I/8NkiUX6mjihe9Fh9+muT6odmob V/EWLDq2ZOT2jspDCS6bM8yhQr04djyDmpommaFkF74XsevN2quRNTj/wzHuZqS8f4Fy jLzWt1j2Y3lqE6NAYSG4lB2QXEoxWUzI46tOxVb1SlnU7C22M2HG5Q1HaolESv9CHcaj J1lg== X-Gm-Message-State: ALoCoQm2Fkf2a+vXibLwcpoEuh0XOx4XF9DxjB3ayvKKo/P4Jm2Ur6UZxHKhgGRORhOlU2rNPSyHtePYzDoRkec0++JQ2IqX6dWOkUitCD4Xeq6UrpZJNc4goEJ+IxlhnZrXFCIeX+agT5Utn7CoYMmJj2NwEUNByA== MIME-Version: 1.0 X-Received: by 10.52.165.65 with SMTP id yw1mr2575779vdb.51.1427189305579; Tue, 24 Mar 2015 02:28:25 -0700 (PDT) Received: by 10.52.248.36 with HTTP; Tue, 24 Mar 2015 02:28:25 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 Mar 2015 12:28:25 +0300 Message-ID: To: Nikita Popov Cc: Xinchen Hui , Joe Watkins , PHP Internals Content-Type: multipart/alternative; boundary=001a11c29cc096340905120567c4 Subject: Re: Use "ropes" for string concatenation From: dmitry@zend.com (Dmitry Stogov) --001a11c29cc096340905120567c4 Content-Type: text/plain; charset=UTF-8 I thought about something like this :) In my opinion UString is really not a proper way to implement Unicoide, but I agree not break anything in current stage. Anyway, please review the first PR (in my opinion it is safe to commit), but you may find some other issues. Thanks. Dmitry. On Tue, Mar 24, 2015 at 12: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. > > Nikita > --001a11c29cc096340905120567c4--