Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-30705] Optimize TagCloud calculation
  • Loading branch information
olivergondza committed Sep 29, 2015
1 parent 699d2b2 commit 1b85201
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/main/java/hudson/model/Label.java
Expand Up @@ -85,6 +85,7 @@ public abstract class Label extends Actionable implements Comparable<Label>, Mod
protected transient final String name;
private transient volatile Set<Node> nodes;
private transient volatile Set<Cloud> clouds;
private transient volatile int tiedJobsCount;

@Exported
public transient final LoadStatistics loadStatistics;
Expand Down Expand Up @@ -376,6 +377,8 @@ public List<AbstractProject> getTiedJobs() {
* @return a count of projects that are tied on this node.
*/
public int getTiedJobCount() {
if (tiedJobsCount != -1) return tiedJobsCount;

// denormalize for performance
// we don't need to respect security as much when returning a simple count
SecurityContext context = ACL.impersonate(ACL.SYSTEM);
Expand Down Expand Up @@ -412,7 +415,7 @@ public int getTiedJobCount() {
}
}
}
return result;
return tiedJobsCount = result;
} finally {
SecurityContextHolder.setContext(context);
}
Expand All @@ -433,6 +436,7 @@ public boolean isEmpty() {
/*package*/ void reset() {
nodes = null;
clouds = null;
tiedJobsCount = -1;
}

/**
Expand Down

0 comments on commit 1b85201

Please sign in to comment.