Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-40612

Poor performance of RelocationAction.getIconFileName

XMLWordPrintable

      Encountered something like this in a thread dump:

      "Handling GET /job/.../job/.../job/.../view/All/ from ... : RequestHandlerThread[#...] View/index.jelly View/sidepanel.jelly AbstractFolder/tasks-bottom.jelly" ...
         java.lang.Thread.State: RUNNABLE
      	at java.lang.String$CaseInsensitiveComparator.compare(Unknown Source)
      	at java.lang.String.compareToIgnoreCase(Unknown Source)
      	at hudson.model.Items$2.compare(Items.java:360)
      	at hudson.model.Items$2.compare(Items.java:358)
      	at java.util.TimSort.countRunAndMakeAscending(Unknown Source)
      	at java.util.TimSort.sort(Unknown Source)
      	at java.util.Arrays.sort(Unknown Source)
      	at java.util.ArrayList.sort(Unknown Source)
      	at java.util.Collections.sort(Unknown Source)
      	at hudson.model.Items.getAllItems(Items.java:358)
      	at hudson.model.Items.getAllItems(Items.java:377)
      	at hudson.model.Items.getAllItems(Items.java:377)
      	at hudson.model.Items.getAllItems(Items.java:377)
      	at hudson.model.Items.getAllItems(Items.java:353)
      	at jenkins.model.Jenkins.getAllItems(Jenkins.java:1445)
      	at jenkins.model.Jenkins.getAllItems(Jenkins.java:1454)
      	at com.cloudbees.hudson.plugins.folder.relocate.StandardHandler.validDestinations(StandardHandler.java:85)
      	at com.cloudbees.hudson.plugins.folder.relocate.StandardHandler.applicability(StandardHandler.java:54)
      	at com.cloudbees.hudson.plugins.folder.relocate.DefaultRelocationUI.isAvailable(DefaultRelocationUI.java:67)
      	at com.cloudbees.hudson.plugins.folder.relocate.RelocationAction.getIconFileName(RelocationAction.java:90)
      

      This is silly. We are enumerating all items in the system, and sorting them, just so we can see if there is any place something could be moved into and thus whether we should display a Move link in the sidebar!

      To start with, the sort is unnecessary. Not sure if core APIs currently allow this to be optimized out. Then we should have a lazy iterator and break at the first valid destination; there is no need to collect them all.

      And perhaps we should just unconditionally display the link, at least if there is at least one top-level Folder in Jenkins. If there turns out to be no valid destination when you click the link, we can just show a message to that effect. No need to calculate all this in advance.

            jglick Jesse Glick
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: