[ 
https://issues.apache.org/jira/browse/BEAM-1587?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17546253#comment-17546253
 ] 

Kenneth Knowles commented on BEAM-1587:
---------------------------------------

This issue has been migrated to https://github.com/apache/beam/issues/18135

> 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
>            Priority: P3
>
> 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
(v8.20.7#820007)

Reply via email to