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

Absolutely atrocious user lookup performance when many legacy users

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: core
    • Environment:
      core 2.60.x, Git plugin, and user viewing changesets when a lot of users exist.
    • Epic Link:
    • Similar Issues:

      Description

      The performance of user lookup when many users with legacy config files exist has been identified as the cause of a master's CPU usage spiking to the point of unresponsiveness. 

      Stack trace:

      at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
      at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:242)
      at java.io.File.isFile(File.java:882)
      at hudson.model.User$3.accept(User.java:697)
      at java.io.File.listFiles(File.java:1291)
      at hudson.model.User.getLegacyConfigFilesFor(User.java:694)
      at hudson.model.User.getOrCreate(User.java:437)
      at hudson.model.User.getById(User.java:535)
      at hudson.model.User$UserIDCanonicalIdResolver.resolveCanonicalId(User.java:1086)
      at hudson.model.User.get(User.java:405)
      at hudson.model.User.get(User.java:374)
      at hudson.plugins.git.GitChangeSet.findOrCreateUser(GitChangeSet.java:379)
      at hudson.plugins.git.GitChangeSet.getAuthor(GitChangeSet.java:448)

      The root cause of the problem is that for every user we're doing an O(n) scan through the directories in that folder looking for legacy user config files:

       private static final File[] getLegacyConfigFilesFor(final String id) {
              return getRootDir().listFiles(new FileFilter() {
                  @Override
                  public boolean accept(File pathname) {
                      return pathname.isDirectory() && new File(pathname, "config.xml").isFile() && idStrategy().equals(
                              pathname.getName(), id);
                  }
              });
          }
      
      

      Code here: https://github.com/jenkinsci/jenkins/blob/2d2101215dc39dfcb03279e3cb8898b8b9e5bc5f/core/src/main/java/hudson/model/User.java#L680

      The likely best fix is either to be able to check for a single file (if case sensitive mode is on) or to cache the list of entries in that folder so we don't need to do a listFiles and linear-time scan through all entries with a FileFilter.

        Attachments

          Issue Links

            Activity

            Hide
            jamesdumay James Dumay added a comment -
            Show
            jamesdumay James Dumay added a comment - Oleg Nenashev Jesse Glick nice one
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            Marked the fix as the lts-canididate, but I am not 100% sure it is safe. Jesse Glick WDYT?

            Show
            oleg_nenashev Oleg Nenashev added a comment - Marked the fix as the lts-canididate, but I am not 100% sure it is safe. Jesse Glick WDYT?
            Show
            aheritier Arnaud Héritier added a comment - Oleg Nenashev , Daniel Beck , Jesse Glick , Oliver Gondža https://jenkins.io/changelog-stable/  doesn't list  JENKINS-47429 as fixed in 2.89.2 ? But it seems to be here : https://github.com/jenkinsci/jenkins/commit/b450e9bdb60f6b3a0d492219a026438bf7b3b9d6 JENKINS-48157 , JENKINS-34138 are also missing ?
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            2.89.2 was an out-of-order Security release. The changes listed in 2.89.2-fixed will be actually released in 2.89.3 IIUC, but somebody told me the different thing a while ago. Probably it was you

            Show
            oleg_nenashev Oleg Nenashev added a comment - 2.89.2 was an out-of-order Security release. The changes listed in 2.89.2-fixed will be actually released in 2.89.3 IIUC, but somebody told me the different thing a while ago. Probably it was you
            Show
            danielbeck Daniel Beck added a comment - https://groups.google.com/d/msg/jenkinsci-dev/YNCLWs7cBHc/FKrH97ZoCwAJ

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                svanoort Sam Van Oort
              • Votes:
                2 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: