hadoop-yarn-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Lowe (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (YARN-6768) Improve performance of yarn api record toString and fromString
Date Thu, 13 Jul 2017 17:46:00 GMT

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

Jason Lowe commented on YARN-6768:
----------------------------------

Had an offline discussion with [~jeagles] and [~daryn], and one item that came up during the
discussion was whether we could eliminate both the state (and thus thread safety issues) _and_
the array copy occurring in StringBuilder by doing an algorithm Daryn described like the following
(note I have not tested this):
{code}
  public static StringBuilder format(StringBuilder sb, long value, int minimumDigits) {
    if (value < 0) {
      sb.append('-');
      value = -value;
    }

    int numDigits = 0;
    int tmp = value;
    do {
      ++numDigits;
      tmp /= 10;
    } while (tmp > 0);

    for (int i = minimumDigits - numDigits; i > 0; --i) {
      sb.append('0');
    }

    sb.append(value);
    return sb;
  }
{code}

This has a little bit more computation to compute the number of digits, but it avoids both
thread-local lookups and temp buffer allocation.

> 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, YARN-6768.3.patch
>
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: yarn-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: yarn-issues-help@hadoop.apache.org


Mime
View raw message