Functions.getRelativeLinkTo(Item p) is called quite liberally while rendering Views. It calls view.getItems() which means recalculating the jobs to display. This can lead to performance problems for complex views (e.g. with the view-jobs-filter plugin).

      One idea is to cache the result from ListView.getItems(). Kohsuke created an initial branch for this:
      https://github.com/jenkinsci/jenkins/commits/view-caching

          [JENKINS-18364] Optimize creation of relative links to jobs

          Eric Weikl added a comment - - edited

          Tested with the view-jobs-filter plugin, verified that Kohsuke's branch reduces the call count to ViewJobFilter.filter() to 1

          Eric Weikl added a comment - - edited Tested with the view-jobs-filter plugin , verified that Kohsuke's branch reduces the call count to ViewJobFilter.filter() to 1

          Jesse Glick added a comment -

          Unclear why getRelativeLinkTo is even needed in a typical page render, since View.getItem(String) does not care whether the item is actually in the current view anyway (and why would you be displaying an item not in the current view?). Quick workaround may be to use a weak cache of View.getItems by request (which might be useful anyway).

          Jesse Glick added a comment - Unclear why getRelativeLinkTo is even needed in a typical page render, since View.getItem(String) does not care whether the item is actually in the current view anyway (and why would you be displaying an item not in the current view?). Quick workaround may be to use a weak cache of View.getItems by request (which might be useful anyway).

          Code changed in jenkins
          User: Jesse Glick
          Path:
          changelog.html
          core/src/main/java/hudson/Functions.java
          core/src/test/java/hudson/FunctionsTest.java
          http://jenkins-ci.org/commit/jenkins/bcc86148561ad9ab4a0365ff00d28ff7ee71d57c
          Log:
          [FIXED JENKINS-18364] Functions.getRelativeLinkTo is called many times during rendering, so skip checking View.getItems which is expensive.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: changelog.html core/src/main/java/hudson/Functions.java core/src/test/java/hudson/FunctionsTest.java http://jenkins-ci.org/commit/jenkins/bcc86148561ad9ab4a0365ff00d28ff7ee71d57c Log: [FIXED JENKINS-18364] Functions.getRelativeLinkTo is called many times during rendering, so skip checking View.getItems which is expensive.

          dogfood added a comment -

          Integrated in jenkins_main_trunk #3272
          [FIXED JENKINS-18364] Functions.getRelativeLinkTo is called many times during rendering, so skip checking View.getItems which is expensive. (Revision bcc86148561ad9ab4a0365ff00d28ff7ee71d57c)

          Result = SUCCESS
          Jesse Glick : bcc86148561ad9ab4a0365ff00d28ff7ee71d57c
          Files :

          • core/src/test/java/hudson/FunctionsTest.java
          • core/src/main/java/hudson/Functions.java
          • changelog.html

          dogfood added a comment - Integrated in jenkins_main_trunk #3272 [FIXED JENKINS-18364] Functions.getRelativeLinkTo is called many times during rendering, so skip checking View.getItems which is expensive. (Revision bcc86148561ad9ab4a0365ff00d28ff7ee71d57c) Result = SUCCESS Jesse Glick : bcc86148561ad9ab4a0365ff00d28ff7ee71d57c Files : core/src/test/java/hudson/FunctionsTest.java core/src/main/java/hudson/Functions.java changelog.html

          Daniel Beck added a comment - - edited

          Issue is a performance regression introduced in 1.512, therefore reclassifying as bug to make this eligible for LTS inclusion.

          Measured on a pristine instance with ~8000 freestyle jobs (j0 to j8447), no builds:

          • 1.511: List view with simple regex (j1.*) opens in <1 second
          • 1.512: Same list view opens in 44 seconds, takes 100% CPU during that time.

          Daniel Beck added a comment - - edited Issue is a performance regression introduced in 1.512, therefore reclassifying as bug to make this eligible for LTS inclusion. Measured on a pristine instance with ~8000 freestyle jobs ( j0 to j8447 ), no builds: 1.511: List view with simple regex ( j1.* ) opens in <1 second 1.512: Same list view opens in 44 seconds, takes 100% CPU during that time.

          Please add this to latest lts

          Ireneusz Makowski added a comment - Please add this to latest lts

          Code changed in jenkins
          User: Jesse Glick
          Path:
          changelog.html
          core/src/main/java/hudson/Functions.java
          core/src/test/java/hudson/FunctionsTest.java
          http://jenkins-ci.org/commit/jenkins/98f4b7d99a20252fe64e0ff44ac9375ffc6bc0db
          Log:
          [FIXED JENKINS-18364] Functions.getRelativeLinkTo is called many times during rendering, so skip checking View.getItems which is expensive.
          (cherry picked from commit bcc86148561ad9ab4a0365ff00d28ff7ee71d57c)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: changelog.html core/src/main/java/hudson/Functions.java core/src/test/java/hudson/FunctionsTest.java http://jenkins-ci.org/commit/jenkins/98f4b7d99a20252fe64e0ff44ac9375ffc6bc0db Log: [FIXED JENKINS-18364] Functions.getRelativeLinkTo is called many times during rendering, so skip checking View.getItems which is expensive. (cherry picked from commit bcc86148561ad9ab4a0365ff00d28ff7ee71d57c)

          Pete Ryland added a comment -

          This change looks like it may have caused problems with the radiator plugin. Please see JENKINS-23096.

          Pete Ryland added a comment - This change looks like it may have caused problems with the radiator plugin. Please see JENKINS-23096 .

            jglick Jesse Glick
            ericweikl Eric Weikl
            Votes:
            3 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: