Skip to content

Commit

Permalink
improve JFR custom events
Browse files Browse the repository at this point in the history
  • Loading branch information
danthe1st committed Sep 3, 2024
1 parent 0169ab4 commit 832364f
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.github.danthe1st.arebac.gpeval;

import jdk.jfr.Category;
import jdk.jfr.Description;
import jdk.jfr.Event;
import jdk.jfr.Name;

@Name("io.github.danthe1st.arebac.gpeval.FilterMutualExclusionConstraintEvent")
@Description("filtering mutual exclusion constraints")
@Category("AReBAC")
class FilterMutualExclusionConstraintsEvent extends Event {

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,19 @@
@Category("AReBAC")
class ForwardCheckingEvent extends Event {

@Name("valid neighbors")
@Description("the amount of neighbors processed that satisfy edge/attribute requirements")
private int validNeighborsProcessed;

@Name("total neighbors")
@Description("the total amount of neighbors where edge/attribute requirements were checked")
private int neighborsTotal;

void addNeighborsProcessed(int neighbors) {
this.validNeighborsProcessed += neighbors;
}

void addNeighborsTotal(int neighbors) {
this.neighborsTotal += neighbors;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,12 @@ private GPNode pickNextNode() {
}

private void filterMutualExclusionConstraints(Set<N> candidatesForNode, Set<GPNode> exclusionConstraints, Set<GPNode> incomingConflicts) {
FilterMutualExclusionConstraintsEvent event = new FilterMutualExclusionConstraintsEvent();
event.begin();
for(Iterator<N> it = candidatesForNode.iterator(); it.hasNext();){
filterMutualExclusionConstraintWithSpecificCandidate(exclusionConstraints, incomingConflicts, it);
}

event.commit();
}

private void filterMutualExclusionConstraintWithSpecificCandidate(Set<GPNode> exclusionConstraints, Set<GPNode> incomingConflicts, Iterator<N> it) {
Expand All @@ -267,11 +269,13 @@ private void filterMutualExclusionConstraintWithSpecificCandidate(Set<GPNode> ex
private boolean forwardChecking(GPNode currentNode, Map<GPNode, Set<GPNode>> incomingConflicts, Set<GPNode> outgoingConflicts) {
ForwardCheckingEvent forwardCheckingEvent = new ForwardCheckingEvent();
forwardCheckingEvent.begin();

List<RelevantEdge> relevantEdges = getRelevantEdges(currentNode);
for(RelevantEdge relevantEdge : relevantEdges){
GPNode otherNode = relevantEdge.otherNode();
if(!assignments.containsKey(otherNode)){
List<N> neighbors = getNeighborsSatisfyingEdgeAndAttributeRequirements(currentNode, relevantEdge);
List<N> neighbors = getNeighborsSatisfyingEdgeAndAttributeRequirements(currentNode, relevantEdge, forwardCheckingEvent);
forwardCheckingEvent.addNeighborsProcessed(neighbors.size());
Set<N> otherNodeCandidates = candidates.get(otherNode);
assert otherNodeCandidates == null || !otherNodeCandidates.isEmpty();// I think this shouldn't happen, null is written as empty in the paper
Set<GPNode> otherNodeIncomingConflicts = incomingConflicts.computeIfAbsent(otherNode, n -> new HashSet<>());
Expand All @@ -297,7 +301,7 @@ private boolean forwardChecking(GPNode currentNode, Map<GPNode, Set<GPNode>> inc
return true;
}

private List<N> getNeighborsSatisfyingEdgeAndAttributeRequirements(GPNode currentNode, RelevantEdge relevantEdge) {
private List<N> getNeighborsSatisfyingEdgeAndAttributeRequirements(GPNode currentNode, RelevantEdge relevantEdge, ForwardCheckingEvent forwardCheckingEvent) {
N currentNodeInDB = assignments.get(currentNode);
Collection<E> graphEdges;
Function<E, N> neighborFinder;
Expand All @@ -316,6 +320,9 @@ private List<N> getNeighborsSatisfyingEdgeAndAttributeRequirements(GPNode curren
neighborsSatisfyingRequirements.add(neighbor);
}
}

forwardCheckingEvent.addNeighborsTotal(graphEdges.size());

return neighborsSatisfyingRequirements;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ public class FindEdgesEvent extends Event {
static final String NAME = "io.github.danthe1st.arebac.jfr.events.FindEdgesEvent";

@Label("node ID")
String nodeId;
private String nodeId;

@Label("outgoing")
boolean outgoing;
private boolean outgoing;

@Label("incoming")
boolean incoming;
private boolean incoming;

@Label("foundEdgesCount")
int foundEdgesCount;
private int foundEdgesCount;

public FindEdgesEvent(String nodeId, Direction direction) {
this.nodeId = nodeId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class FindNodeEvent extends Event {
static final String NAME = "io.github.danthe1st.arebac.jfr.events.FindNodeEvent";

@Label("node ID")
String nodeId;
private String nodeId;

public FindNodeEvent(String nodeId) {
this.nodeId = nodeId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class GetAttributeEvent extends Event {

@Label("element ID")
@Description("ID of the node or edge")
String elementId;
private String elementId;

@Label("attribute name")
String attributeName;
private String attributeName;

@Label("element is node")
@Description("true iff this event represents getting the attribute of a node")
boolean isNode;
private boolean isNode;
@Label("element is edge")
@Description("true iff this event represents getting the attribute of a edge")
boolean isEdge;
private boolean isEdge;

public GetAttributeEvent(String elementId, String attributeName, ElementType type) {
this.elementId = elementId;
Expand Down

0 comments on commit 832364f

Please sign in to comment.