From 9e6d8f71ce3f5844b31ed5055ac1354d150edf1f Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 21 Sep 2012 09:12:50 -0700 Subject: [PATCH] build numbers might exhibit some uniformity that makes it problematic with %4==0, so switching to random. The average memory saving should be about the same. --- core/src/main/java/hudson/tasks/Fingerprinter.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/hudson/tasks/Fingerprinter.java b/core/src/main/java/hudson/tasks/Fingerprinter.java index 752d10d3f0..fd81e69999 100644 --- a/core/src/main/java/hudson/tasks/Fingerprinter.java +++ b/core/src/main/java/hudson/tasks/Fingerprinter.java @@ -70,6 +70,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Map.Entry; +import java.util.Random; import java.util.Set; import java.util.TreeMap; import java.util.logging.Level; @@ -295,6 +296,8 @@ public class Fingerprinter extends Recorder implements Serializable, DependecyDe private final AbstractBuild build; + private static final Random rand = new Random(); + /** * From file name to the digest. */ @@ -341,9 +344,9 @@ public class Fingerprinter extends Recorder implements Serializable, DependecyDe public void onLoad() { // share data structure with nearby builds, but to keep lazy loading efficient, - // don't go back the history forever. By %4!=0, 4 neighboring builds will share + // don't go back the history forever. By RAND!=0, 4 neighboring builds will share // the data structure, so we'll get good enough saving. - if (build.getNumber()%4!=0) { + if (rand.nextInt(4)!=0) { Run pb = build.getPreviousBuild(); if (pb!=null) { FingerprintAction a = pb.getAction(FingerprintAction.class); -- GitLab