[ https://issues.apache.org/jira/browse/BEAM-1587?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jingsong Lee reassigned BEAM-1587: ---------------------------------- Assignee: Jingsong Lee (was: Kenneth Knowles) > 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 > Assignee: 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)