From dev-return-8887-apmail-stdcxx-dev-archive=stdcxx.apache.org@stdcxx.apache.org Mon Oct 22 02:35:26 2012 Return-Path: X-Original-To: apmail-stdcxx-dev-archive@www.apache.org Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BFC58D040 for ; Mon, 22 Oct 2012 02:35:26 +0000 (UTC) Received: (qmail 22994 invoked by uid 500); 22 Oct 2012 02:35:26 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 22895 invoked by uid 500); 22 Oct 2012 02:35:25 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 22856 invoked by uid 99); 22 Oct 2012 02:35:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2012 02:35:24 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of msebor@gmail.com designates 209.85.219.54 as permitted sender) Received: from [209.85.219.54] (HELO mail-oa0-f54.google.com) (209.85.219.54) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2012 02:35:15 +0000 Received: by mail-oa0-f54.google.com with SMTP id n9so2060522oag.41 for ; Sun, 21 Oct 2012 19:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=JN5AR6It8r0zD+rz300obF88aKBGTO5gIB9vv0Au8QI=; b=O/xaR547XzipR7t7uFx1VhBM1R8Qf8ww7W8DgSUKUdcp9XqDNgE0/aGpCtyRafmP71 ui5I7UWWs0tjQ5G8n8tukMujw6EgnJo6Y9WCi6mWOU7feNaonUE6vsS9C56jMQtirlIP AHH/qJ7EVtBfIZlFlZ20FWk0k43PU4ECdEbxJ3iJOS/gmC1wkLRX3oFx7cB4NPxeULT5 cZ9x0FCeaaCTHhTDE++ULaExHjgn5PfB5cWNv5tOhDZ56quMpCIZN1amTtQDX1iPyNf9 Q0i+tZ5K4o6ged46eRN8vv0sJGBBM08e8vzAGFFmKtDHZmhBArR2nOghE6leYT2LGJYF Ws3g== Received: by 10.182.116.6 with SMTP id js6mr5749138obb.82.1350873294936; Sun, 21 Oct 2012 19:34:54 -0700 (PDT) Received: from [10.99.105.173] (72-163-0-129.cisco.com. [72.163.0.129]) by mx.google.com with ESMTPS id j19sm4354421oei.2.2012.10.21.19.34.53 (version=SSLv3 cipher=OTHER); Sun, 21 Oct 2012 19:34:54 -0700 (PDT) Message-ID: <5084B0CC.2070801@gmail.com> Date: Sun, 21 Oct 2012 20:34:52 -0600 From: Martin Sebor User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 MIME-Version: 1.0 To: dev@stdcxx.apache.org CC: Liviu Nicoara Subject: Re: std::string reference counting performance References: <50849D58.3030607@hates.ms> In-Reply-To: <50849D58.3030607@hates.ms> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org This is a known problem. The plan is to change the default string implementation in thread-safe configurations in 5.0 from reference counted to deep copying. Until then, it's a library configuration option that must be explicitly enabled. There should be a Jira task to make this change. Martin On 10/21/2012 07:11 PM, Liviu Nicoara wrote: > Hi all, > > I ran the attached test case, s.cpp, and timed it: > > * Deep copy > > $ for f in 16 8 6 4 2 1; do time ./s $f 100000000; done > > 16 0m39.292s 2m34.381s 0m0.035s > 8 0m20.573s 1m18.131s 0m0.025s > 6 0m15.037s 0m58.269s 0m0.009s > 4 0m9.973s 0m38.657s 0m0.009s > 2 0m8.750s 0m17.473s 0m0.016s > 1 0m8.499s 0m8.495s 0m0.002s > > * Shallow copy > > $ for f in 16 8 6 4 2 1; do time ./s $f 100000000; done > > 16 5m29.311s 4m2.107s 17m39.634s > 8 2m43.635s 2m1.823s 8m50.454s > 6 2m10.601s 2m2.316s 6m18.462s > 4 1m20.766s 1m35.383s 3m29.467s > 2 0m25.146s 0m27.775s 0m22.408s > 1 0m3.557s 0m3.555s 0m0.000s > > The results show a counter-intuitive better performance for deep-copied > strings. Again, there is the reversal of performance for one-threaded > programs where there is no contention. > > Liviu