Skip to content

Commit

Permalink
Refactoring downstream dependency cache (#218)
Browse files Browse the repository at this point in the history
Followup on #217. Minor refactoring on downstream dependencies cache implementation, preparing code for the upcoming changes.
  • Loading branch information
nimakarimipour authored Dec 20, 2023
1 parent 9a232d1 commit f773208
Show file tree
Hide file tree
Showing 60 changed files with 251 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import edu.ucr.cs.riple.core.evaluators.suppliers.TargetModuleSupplier;
import edu.ucr.cs.riple.core.injectors.AnnotationInjector;
import edu.ucr.cs.riple.core.injectors.PhysicalInjector;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.core.util.Utility;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import edu.ucr.cs.riple.core.checkers.Checker;
import edu.ucr.cs.riple.core.checkers.CheckerBaseClass;
import edu.ucr.cs.riple.core.log.Log;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.module.ModuleConfiguration;
import edu.ucr.cs.riple.core.module.ModuleInfo;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.injector.offsets.FileOffsetStore;
import edu.ucr.cs.riple.injector.offsets.OffsetChange;
import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import edu.ucr.cs.riple.core.cache.downstream.DownstreamImpactCache;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.module.ModuleInfo;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.injector.location.Location;
import java.util.HashSet;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package edu.ucr.cs.riple.core;

import com.google.common.collect.ImmutableSet;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Fix;
import java.util.HashMap;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
package edu.ucr.cs.riple.core.cache;

import com.google.common.collect.ImmutableSet;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.injector.location.Location;
import java.util.Collection;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
package edu.ucr.cs.riple.core.cache;

import com.google.common.collect.ImmutableSet;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.injector.location.Location;
import java.util.Collection;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
package edu.ucr.cs.riple.core.cache;

import com.google.common.collect.ImmutableSet;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.Fix;
import java.util.Collection;
import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package edu.ucr.cs.riple.core.cache.downstream;

import edu.ucr.cs.riple.core.cache.ImpactCache;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Fix;
import java.util.Set;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
import edu.ucr.cs.riple.core.Report;
import edu.ucr.cs.riple.core.cache.BaseCache;
import edu.ucr.cs.riple.core.evaluators.suppliers.DownstreamDependencySupplier;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.metadata.method.MethodRecord;
import edu.ucr.cs.riple.core.metadata.region.MethodRegionRegistry;
import edu.ucr.cs.riple.core.module.ModuleInfo;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.core.registries.method.MethodRecord;
import edu.ucr.cs.riple.core.registries.region.MethodRegionRegistry;
import edu.ucr.cs.riple.injector.changes.AddMarkerAnnotation;
import edu.ucr.cs.riple.injector.location.Location;
import java.util.Collection;
Expand Down Expand Up @@ -91,7 +91,7 @@ private ImmutableSet<Location> retrieveLocationsToCacheImpactsOnDownstreamDepend
.filter(
input ->
!methodRegionRegistry
.getCallersOfMethod(input.toMethod().clazz, input.toMethod().method)
.getImpactedRegionsByUse(input)
// skip methods that are not called anywhere. This has a significant impact
// on performance.
.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import edu.ucr.cs.riple.core.Report;
import edu.ucr.cs.riple.core.evaluators.BasicEvaluator;
import edu.ucr.cs.riple.core.evaluators.suppliers.DownstreamDependencySupplier;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.injector.location.Location;
import java.util.Set;
import java.util.stream.Collectors;
Expand All @@ -51,30 +51,27 @@ protected void collectGraphResults(ImmutableSet<Report> reports) {
this.graph
.getNodes()
.forEach(
node ->
node.root.ifOnMethod(
method -> {
// Impacted locations.
Set<Location> locations =
node.triggeredErrors.stream()
.filter(
error ->
error.isSingleFix()
// Method is declared in the target module.
&& context.targetModuleInfo.declaredInModule(
error.toResolvingLocation()))
.map(Error::toResolvingLocation)
.collect(Collectors.toSet());
if (!locations.isEmpty()) {
// Update path for each location. These triggered fixes do not have an
// actual physical path since they are provided as a jar file in downstream
// dependencies.
locations.forEach(
location ->
location.path =
context.targetModuleInfo.getLocationOnClass(location.clazz)
.path);
}
}));
node -> {
// Impacted locations.
Set<Location> locations =
node.triggeredErrors.stream()
.filter(
error ->
error.isSingleFix()
// Method is declared in the target module.
&& context.targetModuleInfo.declaredInModule(
error.toResolvingLocation()))
.map(Error::toResolvingLocation)
.collect(Collectors.toSet());
if (!locations.isEmpty()) {
// Update path for each location. These triggered fixes do not have an
// actual physical path since they are provided as a jar file in downstream
// dependencies.
locations.forEach(
location ->
location.path =
context.targetModuleInfo.getLocationOnClass(location.clazz).path);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
package edu.ucr.cs.riple.core.cache.downstream;

import com.google.common.collect.ImmutableSet;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.Fix;
import java.util.Collection;
import java.util.Set;
import javax.annotation.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

import com.google.common.collect.ImmutableSet;
import edu.ucr.cs.riple.core.injectors.AnnotationInjector;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.metadata.region.Region;
import edu.ucr.cs.riple.core.module.ModuleConfiguration;
import edu.ucr.cs.riple.core.module.ModuleInfo;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.core.registries.region.Region;
import java.util.Set;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import edu.ucr.cs.riple.core.Config;
import edu.ucr.cs.riple.core.Context;
import edu.ucr.cs.riple.core.checkers.nullaway.NullAway;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.module.ModuleInfo;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.injector.location.OnField;
import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
import edu.ucr.cs.riple.core.Context;
import edu.ucr.cs.riple.core.checkers.CheckerBaseClass;
import edu.ucr.cs.riple.core.injectors.AnnotationInjector;
import edu.ucr.cs.riple.core.metadata.field.FieldInitializationStore;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.metadata.region.Region;
import edu.ucr.cs.riple.core.module.ModuleConfiguration;
import edu.ucr.cs.riple.core.module.ModuleInfo;
import edu.ucr.cs.riple.core.registries.field.FieldInitializationStore;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.core.registries.region.Region;
import edu.ucr.cs.riple.core.util.Utility;
import edu.ucr.cs.riple.injector.Helper;
import edu.ucr.cs.riple.injector.changes.AddAnnotation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
package edu.ucr.cs.riple.core.checkers.nullaway;

import com.google.common.collect.ImmutableSet;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.metadata.region.Region;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.core.registries.region.Region;
import java.util.Objects;

/** Represents an error reported by {@link NullAway}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import edu.ucr.cs.riple.core.evaluators.graph.ConflictGraph;
import edu.ucr.cs.riple.core.evaluators.graph.processors.ConflictGraphProcessor;
import edu.ucr.cs.riple.core.evaluators.suppliers.Supplier;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Fix;

/**
* Abstract class for evaluators. Subclasses of this evaluator, computes the effectiveness of fix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import edu.ucr.cs.riple.core.Report;
import edu.ucr.cs.riple.core.evaluators.graph.Node;
import edu.ucr.cs.riple.core.evaluators.suppliers.Supplier;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Fix;

/**
* This evaluator for each fix tree computes the effectiveness by injecting the fix tree entirely to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import edu.ucr.cs.riple.core.cache.Impact;
import edu.ucr.cs.riple.core.cache.TargetModuleCache;
import edu.ucr.cs.riple.core.evaluators.suppliers.Supplier;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.Fix;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import com.google.common.collect.ImmutableSet;
import edu.ucr.cs.riple.core.Report;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Fix;

/** Interface for evaluators. Evaluators create reports from the impacts of fixes. */
public interface Evaluator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import com.google.common.collect.ImmutableSet;
import edu.ucr.cs.riple.core.Report;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Fix;

/**
* This evaluator does not evaluate the given fixes based on the impacts on the result of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Fix;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import edu.ucr.cs.riple.core.Report;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.ErrorStore;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.metadata.region.Region;
import edu.ucr.cs.riple.core.metadata.region.RegionRegistry;
import edu.ucr.cs.riple.core.module.ModuleInfo;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.ErrorStore;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.core.registries.region.Region;
import edu.ucr.cs.riple.core.registries.region.RegionRegistry;
import edu.ucr.cs.riple.injector.location.OnMethod;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -109,7 +109,7 @@ public void reCollectPotentiallyImpactedRegions(RegionRegistry regionRegistry) {
// Add origins.
this.regions.addAll(this.origins);
this.tree.forEach(
fix -> regionRegistry.getImpactedRegions(fix.toLocation()).ifPresent(regions::addAll));
fix -> this.regions.addAll(regionRegistry.getImpactedRegions(fix.toLocation())));
// Add class initialization region, if a fix is modifying a parameter on constructor.
this.tree.stream()
.filter(fix -> fix.isOnParameter() && fix.isModifyingConstructor())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import edu.ucr.cs.riple.core.evaluators.graph.Node;
import edu.ucr.cs.riple.core.evaluators.suppliers.Supplier;
import edu.ucr.cs.riple.core.injectors.AnnotationInjector;
import edu.ucr.cs.riple.core.metadata.index.ErrorStore;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.module.ModuleInfo;
import edu.ucr.cs.riple.core.registries.index.ErrorStore;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.injector.changes.AddMarkerAnnotation;
import edu.ucr.cs.riple.injector.location.Location;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import edu.ucr.cs.riple.core.evaluators.graph.ConflictGraph;
import edu.ucr.cs.riple.core.evaluators.graph.Node;
import edu.ucr.cs.riple.core.evaluators.suppliers.Supplier;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.metadata.index.Result;
import edu.ucr.cs.riple.core.metadata.region.Region;
import edu.ucr.cs.riple.core.metadata.region.RegionRegistry;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Result;
import edu.ucr.cs.riple.core.registries.region.Region;
import edu.ucr.cs.riple.core.registries.region.RegionRegistry;
import edu.ucr.cs.riple.core.util.Utility;
import java.util.Collection;
import java.util.HashSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import edu.ucr.cs.riple.core.Context;
import edu.ucr.cs.riple.core.evaluators.graph.ConflictGraph;
import edu.ucr.cs.riple.core.evaluators.suppliers.Supplier;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.metadata.index.Result;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Result;
import edu.ucr.cs.riple.core.util.Utility;
import java.util.Set;
import me.tongfei.progressbar.ProgressBar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

import edu.ucr.cs.riple.core.Context;
import edu.ucr.cs.riple.core.injectors.AnnotationInjector;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.ErrorStore;
import edu.ucr.cs.riple.core.module.ModuleInfo;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.ErrorStore;

/** Base class for all instances of {@link Supplier}. */
public abstract class AbstractSupplier implements Supplier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import edu.ucr.cs.riple.core.evaluators.AbstractEvaluator;
import edu.ucr.cs.riple.core.evaluators.graph.processors.ConflictGraphProcessor;
import edu.ucr.cs.riple.core.injectors.AnnotationInjector;
import edu.ucr.cs.riple.core.metadata.index.Error;
import edu.ucr.cs.riple.core.metadata.index.ErrorStore;
import edu.ucr.cs.riple.core.module.ModuleInfo;
import edu.ucr.cs.riple.core.registries.index.Error;
import edu.ucr.cs.riple.core.registries.index.ErrorStore;

/** Supplier for initializing an {@link AbstractEvaluator} instance. */
public interface Supplier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package edu.ucr.cs.riple.core.injectors;

import edu.ucr.cs.riple.core.Context;
import edu.ucr.cs.riple.core.metadata.index.Fix;
import edu.ucr.cs.riple.core.registries.index.Fix;
import edu.ucr.cs.riple.injector.changes.AddAnnotation;
import edu.ucr.cs.riple.injector.changes.RemoveAnnotation;
import java.util.Set;
Expand Down
Loading

0 comments on commit f773208

Please sign in to comment.