Skip to content

Commit 77c9983

Browse files
authored
Merge pull request #158 from bitwiseman/revert-153
[JENKINS-65885] Revert "Merge pull request #153 from twasyl/synchronization-for-optimisation"
2 parents ed2467f + 6372cff commit 77c9983

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/main/java/org/jenkinsci/plugins/workflow/graph/StandardGraphLookupView.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ public final class StandardGraphLookupView implements GraphLookupView, GraphList
2424

2525
static final String INCOMPLETE = "";
2626

27-
/** Map the blockStartNode to its endNode, to accelerate a range of operations */
27+
/** Map the blockStartNode to its endNode, to accellerate a range of operations */
2828
HashMap<String, String> blockStartToEnd = new HashMap<>();
2929

3030
/** Map a node to its nearest enclosing block */
3131
HashMap<String, String> nearestEnclosingBlock = new HashMap<>();
3232

33-
public synchronized void clearCache() {
33+
public void clearCache() {
3434
blockStartToEnd.clear();
3535
nearestEnclosingBlock.clear();
3636
}
3737

3838
/** Update with a new node added to the flowgraph */
3939
@Override
40-
public synchronized void onNewHead(@Nonnull FlowNode newHead) {
40+
public void onNewHead(@Nonnull FlowNode newHead) {
4141
if (newHead instanceof BlockEndNode) {
4242
blockStartToEnd.put(((BlockEndNode)newHead).getStartNode().getId(), newHead.getId());
4343
String overallEnclosing = nearestEnclosingBlock.get(((BlockEndNode) newHead).getStartNode().getId());
@@ -87,7 +87,7 @@ public boolean isActive(@Nonnull FlowNode node) {
8787
}
8888

8989
// Do a brute-force scan for the block end matching the start, caching info along the way for future use
90-
synchronized BlockEndNode bruteForceScanForEnd(@Nonnull BlockStartNode start) {
90+
BlockEndNode bruteForceScanForEnd(@Nonnull BlockStartNode start) {
9191
DepthFirstScanner scan = new DepthFirstScanner();
9292
scan.setup(start.getExecution().getCurrentHeads());
9393
for (FlowNode f : scan) {
@@ -112,8 +112,11 @@ synchronized BlockEndNode bruteForceScanForEnd(@Nonnull BlockStartNode start) {
112112
return null;
113113
}
114114

115+
116+
117+
115118
/** Do a brute-force scan for the enclosing blocks **/
116-
synchronized BlockStartNode bruteForceScanForEnclosingBlock(@Nonnull final FlowNode node) {
119+
BlockStartNode bruteForceScanForEnclosingBlock(@Nonnull final FlowNode node) {
117120
FlowNode current = node;
118121

119122
while (!(current instanceof FlowStartNode)) { // Hunt back for enclosing blocks, a potentially expensive operation
@@ -154,7 +157,7 @@ synchronized BlockStartNode bruteForceScanForEnclosingBlock(@Nonnull final FlowN
154157

155158
@CheckForNull
156159
@Override
157-
public synchronized BlockEndNode getEndNode(@Nonnull final BlockStartNode startNode) {
160+
public BlockEndNode getEndNode(@Nonnull final BlockStartNode startNode) {
158161

159162
String id = blockStartToEnd.get(startNode.getId());
160163
if (id != null) {
@@ -174,7 +177,7 @@ public synchronized BlockEndNode getEndNode(@Nonnull final BlockStartNode startN
174177

175178
@CheckForNull
176179
@Override
177-
public synchronized BlockStartNode findEnclosingBlockStart(@Nonnull FlowNode node) {
180+
public BlockStartNode findEnclosingBlockStart(@Nonnull FlowNode node) {
178181
if (node instanceof FlowStartNode || node instanceof FlowEndNode) {
179182
return null;
180183
}

0 commit comments

Comments
 (0)