Return-Path: X-Original-To: apmail-tapestry-dev-archive@www.apache.org Delivered-To: apmail-tapestry-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 327341143F for ; Wed, 21 May 2014 13:42:39 +0000 (UTC) Received: (qmail 57328 invoked by uid 500); 21 May 2014 13:42:39 -0000 Delivered-To: apmail-tapestry-dev-archive@tapestry.apache.org Received: (qmail 57273 invoked by uid 500); 21 May 2014 13:42:39 -0000 Mailing-List: contact commits-help@tapestry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tapestry.apache.org Delivered-To: mailing list commits@tapestry.apache.org Received: (qmail 57266 invoked by uid 99); 21 May 2014 13:42:39 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 May 2014 13:42:39 +0000 Date: Wed, 21 May 2014 13:42:39 +0000 (UTC) From: "Jochen Kemnade (JIRA)" To: commits@tapestry.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (TAP5-2332) Get rid of String.format usage MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/TAP5-2332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14004667#comment-14004667 ] Jochen Kemnade commented on TAP5-2332: -------------------------------------- I decided to allow non-null CharSequences only because that's usually what you want to concatenate. Again, this implementation is not meant to replace every possible usage of {{String.fomat}} but only the places where it's used for simple concatenation. And I don't know where "databases" came into play. Even if the application uses one, not all requests are bound to use it. But I think that every request runs through OperationTracker, probably multiple times, and the operation descriptions are often built using String concatenation (see also TAP5-2333). > Get rid of String.format usage > ------------------------------ > > Key: TAP5-2332 > URL: https://issues.apache.org/jira/browse/TAP5-2332 > Project: Tapestry 5 > Issue Type: Improvement > Reporter: Michael Mikhulya > Priority: Minor > Labels: performance > Attachments: 0001-TAP5-2332-get-rid-of-String.format-usage.patch > > > During profiling I found that String.format provides much load on CPU. > In many cases in Tapestry String.format can be easily replaced with simple String concatenation. > Simple JMH (http://openjdk.java.net/projects/code-tools/jmh/) test > {code:java} > public class FormatVsConcat { > private static final String format = "This is a test string with %s"; > private static final String concat1 = "This is a test string with "; > private static final String concat2 = "test word"; > @GenerateMicroBenchmark > public String format() { > return String.format(format, concat2); > } > @GenerateMicroBenchmark > public String concat() { > return concat1 + concat2; > } > } > {code} > shows, that concatenation is 366(!) times faster. > I removed only hot places in tapestry and get following results with apache benchmark: > *Not patched* tapestry version: > Requests per second: *21.38 /sec* (mean) > Time per request: *46.764 [ms]* (mean) > *Patched* tapestry version: > Requests per second: *27.77 /sec* (mean) > Time per request: *36.013 [ms]* (mean) > So we gained 10ms per request or 20% of rendering time. > If you don't mind I would like to get rid of String.format in all places of Tapestry and provide patch. I fixed only hot places which appeared during ab-profiling of one concrete page. So it is very likely that not all hot places were found and fixed. -- This message was sent by Atlassian JIRA (v6.2#6252)