beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jingsong Lee (JIRA)" <j...@apache.org>
Subject [jira] [Assigned] (BEAM-1587) Use StringBuilder to stringKey of StateNamespace instead of String.format
Date Tue, 02 May 2017 13:37:04 GMT

     [ https://issues.apache.org/jira/browse/BEAM-1587?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jingsong Lee reassigned BEAM-1587:
----------------------------------

    Assignee:     (was: Jingsong Lee)

> Use StringBuilder to stringKey of StateNamespace instead of String.format
> -------------------------------------------------------------------------
>
>                 Key: BEAM-1587
>                 URL: https://issues.apache.org/jira/browse/BEAM-1587
>             Project: Beam
>          Issue Type: Improvement
>          Components: runner-core
>            Reporter: Jingsong Lee
>
> In Flink Runner, each State visit will call the namespace stringKey once. Since stringKey
uses String.format to deal with, the impact on performance is relatively large.
> Some extreme cases, stringKey performance consumption of up to 2%.
> Here is a test on StringBuilder and String.format:
> {code}
>   public static void main(String[] args) throws Exception {
>     String[] strs = new String[1000_000];
>     for (int i = 0; i < strs.length; i++) {
>       strs[i] = getRandomString(10);
>     }
>     {
>       long start = System.nanoTime();
>       for (int i = 0; i < strs.length; i++) {
>         strs[i] = testFormat(strs[i]);
>       }
>       System.out.println("testStringFormat: " + ((System.nanoTime() - start)/1000_000)
+ "ms");
>     }
>     {
>       long start = System.nanoTime();
>       for (int i = 0; i < strs.length; i++) {
>         strs[i] = testStringBuild(strs[i]);
>       }
>       System.out.println("testStringBuilder: " + ((System.nanoTime() - start)/1000_000)
+ "ms");
>     }
>   }
> {code}
> testStringFormat: 2312ms
> testStringBuilder: 266ms



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message