Uploaded image for project: 'Hadoop YARN'
  1. Hadoop YARN
  2. YARN-11139

Minor performance improvements in DelegationTokenRenewerPoolTracker

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.3.1, 3.3.3
    • None
    • resourcemanager
    • Hadoop3.3.1 with Kerberos

    Description

      The DelegationTokenRenewerPoolTracker thread wastes of CPU resources when no application running,the run method always executes a for loop, but actually does nothing. 

      // code with no change
      @Override
          public void run() {
            while (true) {
              for (Map.Entry<DelegationTokenRenewerEvent, Future<?>> entry : futures
                  .entrySet()) {
                DelegationTokenRenewerEvent evt = entry.getKey();
                Future<?> future = entry.getValue();
                try {
                  future.get(tokenRenewerThreadTimeout, TimeUnit.MILLISECONDS);
                } catch (TimeoutException e) {
      
                  // Cancel thread and retry the same event in case of timeout
                  if (future != null && !future.isDone() && !future.isCancelled()) {
                    future.cancel(true);
                    futures.remove(evt);
                    if (evt.getAttempt() < tokenRenewerThreadRetryMaxAttempts) {
                      renewalTimer.schedule(
                          getTimerTask((AbstractDelegationTokenRenewerAppEvent) evt),
                          tokenRenewerThreadRetryInterval);
                    } else {
                      LOG.info(
                          "Exhausted max retry attempts {} in token renewer "
                              + "thread for {}",
                          tokenRenewerThreadRetryMaxAttempts, evt.getApplicationId());
                    }
                  }
                } catch (Exception e) {
                  LOG.info("Problem in submitting renew tasks in token renewer "
                      + "thread.", e);
                }
              }
            }
          }
      

      Maybe we can add a tiny sleep to avoid waste of CPU resources. For example below,

      // code with a tiny sleep
          public void run() {
            while (true) {
              try {
                Thread.sleep(1);
              } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
              }
              for (Map.Entry<DelegationTokenRenewerEvent, Future<?>> entry : futures
                  .entrySet()) {
                DelegationTokenRenewerEvent evt = entry.getKey();
      ... 

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              YulongZ YulongZ
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m