Skip to content

Commit

Permalink
Merge pull request #158 from bitwiseman/revert-153
Browse files Browse the repository at this point in the history
[JENKINS-65885] Revert "Merge pull request #153 from twasyl/synchronization-for-optimisation"
  • Loading branch information
bitwiseman authored Jun 16, 2021
2 parents ed2467f + 6372cff commit 77c9983
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ public final class StandardGraphLookupView implements GraphLookupView, GraphList

static final String INCOMPLETE = "";

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

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

public synchronized void clearCache() {
public void clearCache() {
blockStartToEnd.clear();
nearestEnclosingBlock.clear();
}

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

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




/** Do a brute-force scan for the enclosing blocks **/
synchronized BlockStartNode bruteForceScanForEnclosingBlock(@Nonnull final FlowNode node) {
BlockStartNode bruteForceScanForEnclosingBlock(@Nonnull final FlowNode node) {
FlowNode current = node;

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

@CheckForNull
@Override
public synchronized BlockEndNode getEndNode(@Nonnull final BlockStartNode startNode) {
public BlockEndNode getEndNode(@Nonnull final BlockStartNode startNode) {

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

@CheckForNull
@Override
public synchronized BlockStartNode findEnclosingBlockStart(@Nonnull FlowNode node) {
public BlockStartNode findEnclosingBlockStart(@Nonnull FlowNode node) {
if (node instanceof FlowStartNode || node instanceof FlowEndNode) {
return null;
}
Expand Down

0 comments on commit 77c9983

Please sign in to comment.