Merely calling job.getBuilds().isEmpty() breaks lazy-loading:

      	at hudson.model.Run.onLoad(Run.java:319)
      	at hudson.model.RunMap.retrieve(RunMap.java:226)
      	at hudson.model.RunMap.retrieve(RunMap.java:59)
      	at jenkins.model.lazy.AbstractLazyLoadRunMap.load(AbstractLazyLoadRunMap.java:667)
      	at jenkins.model.lazy.AbstractLazyLoadRunMap.load(AbstractLazyLoadRunMap.java:650)
      	at jenkins.model.lazy.AbstractLazyLoadRunMap.all(AbstractLazyLoadRunMap.java:602)
      	at jenkins.model.lazy.AbstractLazyLoadRunMap.entrySet(AbstractLazyLoadRunMap.java:264)
      	at java.util.AbstractMap$2$1.<init>(AbstractMap.java:378)
      	at java.util.AbstractMap$2.iterator(AbstractMap.java:377)
      	at hudson.util.RunList$2.iterator(RunList.java:213)
      	at hudson.util.RunList.iterator(RunList.java:103)
      	at hudson.util.RunList.isEmpty(RunList.java:173)
      

      You would reasonably expect this method, and anything simply iterating builds, to be lazy, but it is eager.

          [JENKINS-18065] AbstractLazyLoadRunMap.iterator() calls .all()

          Jesse Glick created issue -
          Jesse Glick made changes -
          Link New: This issue is related to JENKINS-8754 [ JENKINS-8754 ]

          Jesse Glick added a comment -

          Seems to me that AbstractLazyLoadRunMap.all could simply create an empty BuildReference for each ID on disk, rather than calling load. Then the entrySet would have the right keys, and if and when you actually tried to access a value for an entry, BuildReferenceMapAdapter.unwrap would call getById and thus load for that one build. Right?

          Jesse Glick added a comment - Seems to me that AbstractLazyLoadRunMap.all could simply create an empty BuildReference for each ID on disk, rather than calling load . Then the entrySet would have the right keys, and if and when you actually tried to access a value for an entry, BuildReferenceMapAdapter.unwrap would call getById and thus load for that one build. Right?

          Jesse Glick added a comment -

          To answer my own question: wrong—because it is returning a map keyed by build number, which cannot be determined until records are loaded. So a fix would need to be trickier: would need to make some operations on the entry set eager (preferably ones no one is likely to call), but make .entrySet().iterator() (as used by .size() or simply anyone using a for-loop) load entries on demand in reverse numeric order.

          Jesse Glick added a comment - To answer my own question: wrong—because it is returning a map keyed by build number, which cannot be determined until records are loaded. So a fix would need to be trickier: would need to make some operations on the entry set eager (preferably ones no one is likely to call), but make .entrySet().iterator() (as used by .size() or simply anyone using a for-loop) load entries on demand in reverse numeric order.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          core/src/test/java/jenkins/model/lazy/AbstractLazyLoadRunMapTest.java
          http://jenkins-ci.org/commit/jenkins/5903870d318a337548e3f7ef75603f75a378e7ac
          Log:
          JENKINS-18065 Documenting current misbehavior in a unit test.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/test/java/jenkins/model/lazy/AbstractLazyLoadRunMapTest.java http://jenkins-ci.org/commit/jenkins/5903870d318a337548e3f7ef75603f75a378e7ac Log: JENKINS-18065 Documenting current misbehavior in a unit test.

          dogfood added a comment -

          Integrated in jenkins_main_trunk #2574
          JENKINS-18065 Documenting current misbehavior in a unit test. (Revision 5903870d318a337548e3f7ef75603f75a378e7ac)

          Result = SUCCESS
          Jesse Glick : 5903870d318a337548e3f7ef75603f75a378e7ac
          Files :

          • core/src/test/java/jenkins/model/lazy/AbstractLazyLoadRunMapTest.java

          dogfood added a comment - Integrated in jenkins_main_trunk #2574 JENKINS-18065 Documenting current misbehavior in a unit test. (Revision 5903870d318a337548e3f7ef75603f75a378e7ac) Result = SUCCESS Jesse Glick : 5903870d318a337548e3f7ef75603f75a378e7ac Files : core/src/test/java/jenkins/model/lazy/AbstractLazyLoadRunMapTest.java
          Jesse Glick made changes -
          Labels Original: lts-candidate performance New: lazy-loading lts-candidate performance

          Jesse Glick added a comment -

          Seems to block the attempted fix of JENKINS-20892 from actually working, at least in the case of BuildTimelineWidget.

          Jesse Glick added a comment - Seems to block the attempted fix of JENKINS-20892 from actually working, at least in the case of BuildTimelineWidget .
          Jesse Glick made changes -
          Link New: This issue is blocking JENKINS-20892 [ JENKINS-20892 ]
          Jesse Glick made changes -
          Assignee New: Kohsuke Kawaguchi [ kohsuke ]

            kohsuke Kohsuke Kawaguchi
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: