You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/03 16:23:59 UTC

[GitHub] [beam] kennknowles opened a new issue, #18135: Use StringBuilder to stringKey of StateNamespace instead of String.format

kennknowles opened a new issue, #18135:
URL: https://github.com/apache/beam/issues/18135

   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:
   ```
   
     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");
       }
     }
   
   ```
   
   testStringFormat: 2312ms
   testStringBuilder: 266ms
   
   Imported from Jira [BEAM-1587](https://issues.apache.org/jira/browse/BEAM-1587). Original Jira may contain additional context.
   Reported by: lzljs3620320.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org