Skip to content

[JENKINS-19400] Configurable retention system for lazy-loaded build references #14887

Closed

Description

@jenkins-infra-bot

Since 1.485 Jenkins keeps lazy-loaded builds held via SoftReference. This is normally appropriate—you want to hold them as long as possible, but without exhausting the heap. Still, there are reasons why you would prefer a different strategy. If you are pushing up against heap limits, other lazy-loading bugs might cause Jenkins to repeatedly load and then drop build records, causing slow performance and lots of disk I/O. If you want to reproduce a lazy-loading bug, the unpredictability of soft reference GC complicates things. So there should be an option (I guess a system property) to control how a BuildRef holds its referent:

1. As a soft reference, as now.
2. Using a hard reference, never released. (This is not the same as pre-1.485 behavior since the first load is still lazy.)
3. A hard reference released after a certain amount of time has elapsed since the last time the reference was traversed.
4. A hard reference so long as the maximum number of such references is not exceeded (i.e. a LRU list).
5. Not held at all (just for testing behavior of initial load without actually needing to restart Jenkins).
6. Perhaps soft or weak variants of #3 and #4, i.e. initially a hard reference, then downgraded rather than released entirely.


Originally reported by jglick, imported from: Configurable retention system for lazy-loaded build references
  • assignee: jglick
  • status: Resolved
  • priority: Major
  • component(s): core
  • label(s): lazy-loading, memory, performance, testing
  • resolution: Fixed
  • resolved: 2014-01-09T02:14:39+00:00
  • votes: 2
  • watchers: 6
  • imported: 2025-11-24
Raw content of original issue

Since 1.485 Jenkins keeps lazy-loaded builds held via SoftReference. This is normally appropriate—you want to hold them as long as possible, but without exhausting the heap. Still, there are reasons why you would prefer a different strategy. If you are pushing up against heap limits, other lazy-loading bugs might cause Jenkins to repeatedly load and then drop build records, causing slow performance and lots of disk I/O. If you want to reproduce a lazy-loading bug, the unpredictability of soft reference GC complicates things. So there should be an option (I guess a system property) to control how a BuildRef holds its referent:

1. As a soft reference, as now. 2. Using a hard reference, never released. (This is not the same as pre-1.485 behavior since the first load is still lazy.) 3. A hard reference released after a certain amount of time has elapsed since the last time the reference was traversed. 4. A hard reference so long as the maximum number of such references is not exceeded (i.e. a LRU list). 5. Not held at all (just for testing behavior of initial load without actually needing to restart Jenkins). 6. Perhaps soft or weak variants of #3 and #4, i.e. initially a hard reference, then downgraded rather than released entirely.

Activity

  1. jenkins-infra-bot commented on Sep 18, 2013

    @jenkins-infra-bot
    Author
    kohsuke:
    • Original comment link
    • Raw content of original comment:

      I agree this is a good change.

      One possibly easy way to fix this is by having another strong reference to the build from BuildRef as opposed to make it not to extend WeakReference.

    I agree this is a good change.

    One possibly easy way to fix this is by having another strong reference to the build from BuildRef as opposed to make it not to extend WeakReference.

  2. jenkins-infra-bot commented on Jan 9, 2014

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: Jesse Glick
    Path:
    core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java
    core/src/main/java/jenkins/model/lazy/BuildReference.java
    http://jenkins-ci.org/commit/jenkins/89d7570ddd143c197d394bf2b4f5b34e15cbecdc
    Log:
    [FIXED JENKINS-19400] Configurable retention system for lazy-loaded build references.

  3. jenkins-infra-bot commented on Jan 9, 2014

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: Jesse Glick
    Path:
    changelog.html
    core/src/main/java/jenkins/model/lazy/BuildReference.java
    http://jenkins-ci.org/commit/jenkins/bbe36a5aaa862d0d93430b73ae668e131c3c9120
    Log:
    [FIXED JENKINS-19400] Noting merge of #1055: BuildReference.HolderFactory.

    Compare: 0e00797...bbe36a5

  4. jenkins-infra-bot commented on Jan 9, 2014

    @jenkins-infra-bot
    Author
    dogfood:
    • Original comment link
    • Raw content of original comment:

      Integrated in jenkins_main_trunk #3155 [FIXED JENKINS-19400] Configurable retention system for lazy-loaded build references. (Revision 89d7570ddd143c197d394bf2b4f5b34e15cbecdc) [FIXED JENKINS-19400] Noting merge of #1055: BuildReference.HolderFactory. (Revision bbe36a5aaa862d0d93430b73ae668e131c3c9120)

      Result = SUCCESS Jesse Glick : 89d7570ddd143c197d394bf2b4f5b34e15cbecdc Files :

      • core/src/main/java/jenkins/model/lazy/BuildReference.java
      • core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java

      Jesse Glick : bbe36a5aaa862d0d93430b73ae668e131c3c9120 Files :

      • changelog.html
      • core/src/main/java/jenkins/model/lazy/BuildReference.java

    Integrated in jenkins_main_trunk #3155
    [FIXED JENKINS-19400] Configurable retention system for lazy-loaded build references. (Revision 89d7570)
    [FIXED JENKINS-19400] Noting merge of #1055: BuildReference.HolderFactory. (Revision bbe36a5)

    Result = SUCCESS
    Jesse Glick : 89d7570ddd143c197d394bf2b4f5b34e15cbecdc
    Files :

    • core/src/main/java/jenkins/model/lazy/BuildReference.java
    • core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java

    Jesse Glick : bbe36a5aaa862d0d93430b73ae668e131c3c9120
    Files :

    • changelog.html
    • core/src/main/java/jenkins/model/lazy/BuildReference.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions