[ https://issues.apache.org/jira/browse/YARN-6768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16078159#comment-16078159 ]
Jason Lowe commented on YARN-6768: ---------------------------------- Thanks for the patch! Curious if this would be simpler and maybe faster to avoid having any state. Avoiding state prevents thread safety issues requiring thread local use, making it easier to use correctly. For example, something like this: {code} public static StringBuilder format(StringBuilder sb, long source, int minimumDigits) { char[] digits = new char[MAX_COUNT]; int left = MAX_COUNT; if (source < 0) { sb.append('-'); source = - source; } while (source > 0) { digits[--left] = (char)('0' + (source % 10)); source /= 10; } while (MAX_COUNT - left < minimumDigits) { digits[--left] = '0'; } sb.append(digits, left, MAX_COUNT - left); return sb; } {code} I suspect simple String object allocation and thread local lookup are comparable in performance, although I haven't benchmarked it. > Improve performance of yarn api record toString and fromString > -------------------------------------------------------------- > > Key: YARN-6768 > URL: https://issues.apache.org/jira/browse/YARN-6768 > Project: Hadoop YARN > Issue Type: Improvement > Reporter: Jonathan Eagles > Assignee: Jonathan Eagles > Attachments: YARN-6768.1.patch, YARN-6768.2.patch > > -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: yarn-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org