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

Performance issue with promoted builds and Git branch parameter

      When accessing any page featuring a build with promotions (eg. job page, but also job list where promotion icon column is enabled), we are experiencing extremely poor performance.

      I had a look at the stack while this was going on and it seems to be because of something related to having a build parameter tied to Git branches:

       

      Handling GET /job/MyJob/ from 127.0.0.1 : qtp19448387-247861 Job/index.jelly AbstractProject/sidepanel.jelly HistoryWidget/index.jelly HistoryPageFilter/entries.jelly HistoryPageFilter/entries.jelly HistoryPageFilter/entry.jelly PromotedBuildAction/badge.jelly
      java.lang.ProcessImpl.waitForInterruptibly(Native Method)
      java.lang.ProcessImpl.waitFor(Unknown Source)
      hudson.Proc$LocalProc.join(Proc.java:324)
      hudson.Proc.joinWithTimeout(Proc.java:170)
      org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2012)
      org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1735)
      org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1640)
      org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1631)
      org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getRemoteReferences(CliGitAPIImpl.java:2851)
      net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition.getBranch(GitParameterDefinition.java:392)
      net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition.generateContents(GitParameterDefinition.java:315)
      net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition$DescriptorImpl.doFillValueItems(GitParameterDefinition.java:633)
      net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition.getDefaultParameterValue(GitParameterDefinition.java:163)
      hudson.plugins.promoted_builds.PromotionProcess.getDefaultParameterValuesAsEnvVars(PromotionProcess.java:300)
      hudson.plugins.promoted_builds.PromotionProcess.isVisible(PromotionProcess.java:281)
      

      Pages will take upwards of minutes to finish loading. Turning off promoted builds or Git branch parameter for a job will restore performance back to typical load times.

      Please let me know if there is anything you need me to try out.

          [JENKINS-54504] Performance issue with promoted builds and Git branch parameter

          Devin Nusbaum added a comment - - edited

          Maybe the Promoted Builds Plugin should cache the result of PromotionProcess#isVisible in the isVisible field so that the git parameter plugin doesn't have to make so many remote calls or make the feature added in https://github.com/jenkinsci/promoted-builds-plugin/pull/76 able to be disabled so these calls aren't made in the first place, but I'm not really familiar with how the feature is supposed to work in the first place.

          I'm not sure if the git parameter plugin could do anything to optimize getting the default parameter value CC klimas7.

          I do not expect to have time to work on this myself, but I am happy to help review any PRs that you submit. Here is the code that I would investigate: https://github.com/jenkinsci/promoted-builds-plugin/blob/e4c9304553f2868f67556644f5831eba60cf2c34/src/main/java/hudson/plugins/promoted_builds/PromotionProcess.java#L273.

          Devin Nusbaum added a comment - - edited Maybe the Promoted Builds Plugin should cache the result of PromotionProcess#isVisible in the isVisible field so that the git parameter plugin doesn't have to make so many remote calls or make the feature added in https://github.com/jenkinsci/promoted-builds-plugin/pull/76 able to be disabled so these calls aren't made in the first place, but I'm not really familiar with how the feature is supposed to work in the first place. I'm not sure if the git parameter plugin could do anything to optimize getting the default parameter value CC klimas7 . I do not expect to have time to work on this myself, but I am happy to help review any PRs that you submit. Here is the code that I would investigate: https://github.com/jenkinsci/promoted-builds-plugin/blob/e4c9304553f2868f67556644f5831eba60cf2c34/src/main/java/hudson/plugins/promoted_builds/PromotionProcess.java#L273 .

          Boguslaw Klimas added a comment - - edited

          Hi,

          If you haven't set 'Default Value' and you have 'Selected Value' set as TOP, during invoke method getDefaultParameterValue by PromotionProcess.getDefaultParameterValuesAsEnvVars
          plugin invoke git command look on github.

          Perhaps the solution to this issue will be setting a 'Default Value' in git-parameter plugin

           

           

          Boguslaw Klimas added a comment - - edited Hi, If you haven't set 'Default Value' and you have 'Selected Value' set as TOP, during invoke method getDefaultParameterValue by PromotionProcess.getDefaultParameterValuesAsEnvVars plugin invoke git command look on github . Perhaps the solution to this issue will be setting a 'Default Value' in git-parameter plugin    

          klimas7 thank you! Setting a default value helped massively. We were indeed using TOP with no default value. After setting a default value the job pages now load very quickly.

          I am not well versed in Java, so I'm not sure I can provide a PR myself. I will try to take a look at a permanent fix if I have some time.

          Josh Schreuder added a comment - klimas7 thank you! Setting a default value helped massively. We were indeed using TOP with no default value. After setting a default value the job pages now load very quickly. I am not well versed in Java, so I'm not sure I can provide a PR myself. I will try to take a look at a permanent fix if I have some time.

          Devin Nusbaum added a comment -

          joshschreuder Glad to hear that helped! It's up to you whether you want to work on it. While I am not very familiar with the APIs involved, my guess is that getDefaultParameterValue is normally a very quick operation, so the usage in promoted-builds should be fine as-is for the majority of cases, so I would be ok with just closing this issue for now, and we can revisit it if it becomes a widespread issue in the future.

          Devin Nusbaum added a comment - joshschreuder Glad to hear that helped! It's up to you whether you want to work on it. While I am not very familiar with the APIs involved, my guess is that getDefaultParameterValue is normally a very quick operation, so the usage in promoted-builds should be fine as-is for the majority of cases, so I would be ok with just closing this issue for now, and we can revisit it if it becomes a widespread issue in the future.

            Unassigned Unassigned
            joshschreuder Josh Schreuder
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: