Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove conflict analysis #787

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Src/PChecker/CheckerCore/CheckerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,6 @@ public int MaxSchedulingSteps
[DataMember]
public string JvmArgs;

/// <summary>
/// Enable conflict analysis for scheduling optimization.
/// </summary>
[DataMember]
public bool EnableConflictAnalysis;

/// <summary>
/// Initializes a new instance of the <see cref="CheckerConfiguration"/> class.
Expand Down Expand Up @@ -337,7 +332,6 @@ protected CheckerConfiguration()

EnableColoredConsoleOutput = false;
DisableEnvironmentExit = true;
EnableConflictAnalysis = false;

PSymArgs = "";
JvmArgs = "";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public POSScheduleGenerator Mutate(POSScheduleGenerator prev)
{
return new POSScheduleGenerator(prev.Random,
Utils.MutateRandomChoices(prev.PriorityChoices, _meanMutationCount, _meanMutationSize, _random),
Utils.MutateRandomChoices(prev.SwitchPointChoices, _meanMutationCount, _meanMutationSize, _random),
prev.Monitor
);
Utils.MutateRandomChoices(prev.SwitchPointChoices, _meanMutationCount, _meanMutationSize, _random));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,21 @@ internal class POSScheduleGenerator: POSScheduler, IScheduleGenerator<POSSchedul
public System.Random Random;
public RandomChoices<int> PriorityChoices;
public RandomChoices<double> SwitchPointChoices;
public ConflictOpMonitor? Monitor;

public POSScheduleGenerator(System.Random random, RandomChoices<int>? priorityChoices, RandomChoices<double>? switchPointChoices,
ConflictOpMonitor? monitor):
public POSScheduleGenerator(System.Random random, RandomChoices<int>? priorityChoices, RandomChoices<double>? switchPointChoices):
base(new ParametricProvider(
priorityChoices != null ? new RandomChoices<int>(priorityChoices) : new RandomChoices<int>(random),
switchPointChoices != null ? new RandomChoices<double>(switchPointChoices) : new RandomChoices<double>(random)),
monitor)
switchPointChoices != null ? new RandomChoices<double>(switchPointChoices) : new RandomChoices<double>(random)))
{
Random = random;
var provider = (ParametricProvider) Provider;
PriorityChoices = provider.PriorityChoices;
SwitchPointChoices = provider.SwitchPointChoices;
Monitor = monitor;
}

public POSScheduleGenerator(CheckerConfiguration checkerConfiguration, ConflictOpMonitor? monitor):
public POSScheduleGenerator(CheckerConfiguration checkerConfiguration):
this(new System.Random((int?)checkerConfiguration.RandomGeneratorSeed ?? Guid.NewGuid().GetHashCode()), null,
null, monitor)
null)
{
}

Expand All @@ -42,12 +38,12 @@ public POSScheduleGenerator Mutate()

public POSScheduleGenerator New()
{
return new POSScheduleGenerator(Random, null, null, Monitor);
return new POSScheduleGenerator(Random, null, null);
}

public POSScheduleGenerator Copy()
{
return new POSScheduleGenerator(Random, PriorityChoices, SwitchPointChoices, Monitor);
return new POSScheduleGenerator(Random, PriorityChoices, SwitchPointChoices);
}

public AsyncOperation? NextRandomOperation(List<AsyncOperation> enabledOperations, AsyncOperation current)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@ internal class POSScheduler: PrioritizedScheduler
/// List of prioritized operations.
/// </summary>
private readonly List<AsyncOperation> PrioritizedOperations;

public ConflictOpMonitor? ConflictOpMonitor;


/// <summary>
/// Initializes a new instance of the <see cref="PCTStrategy"/> class.
/// </summary>
public POSScheduler(PriorizationProvider provider, ConflictOpMonitor? monitor)
public POSScheduler(PriorizationProvider provider)
{
Provider = provider;
PrioritizedOperations = new List<AsyncOperation>();
ConflictOpMonitor = monitor;
}

public bool GetNextOperation(AsyncOperation current, IEnumerable<AsyncOperation> ops, out AsyncOperation next)
Expand Down Expand Up @@ -123,11 +120,6 @@ private AsyncOperation GetPrioritizedOperation(List<AsyncOperation> ops, AsyncOp
private bool FindNonRacingOperation(IEnumerable<AsyncOperation> ops, out AsyncOperation next)
{
var nonRacingOps = ops.Where(op => op.Type != AsyncOperationType.Send);
if (!nonRacingOps.Any() && ConflictOpMonitor != null)
{
nonRacingOps = ops.Where(op => !ConflictOpMonitor.IsConflictingOp(op));
}

if (!nonRacingOps.Any())
{
next = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,19 @@ internal class PriorizationSchedulingBase
/// </summary>
private readonly List<AsyncOperation> PrioritizedOperations;

public ConflictOpMonitor? ConflictOpMonitor;
private int _nextPriorityChangePoint;
private int _numSwitchPointsLeft;

/// <summary>
/// Initializes a new instance of the <see cref="PCTStrategy"/> class.
/// </summary>
public PriorizationSchedulingBase(int maxPrioritySwitchPoints, int scheduleLength, PriorizationProvider provider, ConflictOpMonitor? monitor)
public PriorizationSchedulingBase(int maxPrioritySwitchPoints, int scheduleLength, PriorizationProvider provider)
{
Provider = provider;
ScheduledSteps = 0;
ScheduleLength = scheduleLength;
MaxPrioritySwitchPoints = maxPrioritySwitchPoints;
PrioritizedOperations = new List<AsyncOperation>();
ConflictOpMonitor = monitor;
_numSwitchPointsLeft = maxPrioritySwitchPoints;

double switchPointProbability = 0.1;
Expand All @@ -66,7 +64,7 @@ public virtual bool GetNextOperation(AsyncOperation current, IEnumerable<AsyncOp
var enabledOperations = ops.Where(op => op.Status is AsyncOperationStatus.Enabled).ToList();
if (enabledOperations.Count == 0)
{
if (ConflictOpMonitor == null && _nextPriorityChangePoint == ScheduledSteps)
if (_nextPriorityChangePoint == ScheduledSteps)
{
MovePriorityChangePointForward();
}
Expand All @@ -78,25 +76,9 @@ public virtual bool GetNextOperation(AsyncOperation current, IEnumerable<AsyncOp
{
next = highestEnabledOp;
}
if (ConflictOpMonitor != null)
{
ResetPriorities(next, enabledOperations);
}

return true;
}

public void ResetPriorities(AsyncOperation next, IEnumerable<AsyncOperation> ops)
{
foreach (var op in ops)
{
if (op != next && ConflictOpMonitor.IsRacing(next, op))
{
PrioritizedOperations.Remove(op);
}
}
PrioritizedOperations.Remove(next);
}

private void MovePriorityChangePointForward()
{
Expand Down Expand Up @@ -137,13 +119,8 @@ private AsyncOperation GetPrioritizedOperation(List<AsyncOperation> ops, AsyncOp
Debug.WriteLine("<PCTLog> Detected new operation '{0}' at index '{1}'.", op.Id, mIndex);
}

if (ConflictOpMonitor != null && FindNonRacingOperation(ops, out var next))
{
return next;
}

var prioritizedSchedulable = GetHighestPriorityEnabledOperation(ops);
if (ConflictOpMonitor == null && _nextPriorityChangePoint == ScheduledSteps)
if (_nextPriorityChangePoint == ScheduledSteps)
{
if (ops.Count == 1)
{
Expand Down Expand Up @@ -190,32 +167,6 @@ private AsyncOperation GetPrioritizedOperation(List<AsyncOperation> ops, AsyncOp
return ops.First(op => op.Equals(prioritizedSchedulable));
}

private bool FindNonRacingOperation(IEnumerable<AsyncOperation> ops, out AsyncOperation next)
{
var nonRacingOps = ops.Where(op => op.Type != AsyncOperationType.Send);
if (!nonRacingOps.Any())
{
var sendOps = ops.Where(op => op.Type == AsyncOperationType.Send);
nonRacingOps = ops.Where(op => !ConflictOpMonitor.IsConflictingOp(op));
}

if (!nonRacingOps.Any())
{
next = null;
return false;
}
else if (!nonRacingOps.Skip(1).Any())
{
next = nonRacingOps.First();
return true;
}
else
{
next = GetHighestPriorityEnabledOperation(nonRacingOps);
return true;
}

}

public void Reset()
{
Expand Down
23 changes: 2 additions & 21 deletions Src/PChecker/CheckerCore/SystematicTesting/TestingEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ public class TestingEngine
/// </summary>
internal readonly ISchedulingStrategy Strategy;

/// <summary>
/// Monitors conflict operations used by the POS Strategy.
/// </summary>
private ConflictOpMonitor? _conflictOpObserver;

/// <summary>
/// Random value generator used by the scheduling strategies.
/// </summary>
Expand Down Expand Up @@ -303,12 +298,6 @@ private TestingEngine(CheckerConfiguration checkerConfiguration, TestMethodInfo
{
JsonVerboseLogs = new List<List<LogEntry>>();
}

if (checkerConfiguration.EnableConflictAnalysis)
{
_conflictOpObserver = new ConflictOpMonitor();
}

if (checkerConfiguration.SchedulingStrategy is "replay")
{
var scheduleDump = GetScheduleForReplay(out var isFair);
Expand All @@ -328,8 +317,7 @@ private TestingEngine(CheckerConfiguration checkerConfiguration, TestMethodInfo
}
else if (checkerConfiguration.SchedulingStrategy is "pos")
{
var scheduler = new POSScheduler(new RandomPriorizationProvider(RandomValueGenerator),
_conflictOpObserver);
var scheduler = new POSScheduler(new RandomPriorizationProvider(RandomValueGenerator));
Strategy = new PrioritizedSchedulingStrategy(checkerConfiguration.MaxUnfairSchedulingSteps,
RandomValueGenerator, scheduler);
}
Expand Down Expand Up @@ -372,7 +360,7 @@ private TestingEngine(CheckerConfiguration checkerConfiguration, TestMethodInfo
Strategy = new FeedbackGuidedStrategy<RandomInputGenerator, POSScheduleGenerator>(
_checkerConfiguration,
new RandomInputGenerator(checkerConfiguration),
new POSScheduleGenerator(_checkerConfiguration, _conflictOpObserver));
new POSScheduleGenerator(_checkerConfiguration));
}
else if (checkerConfiguration.SchedulingStrategy is "portfolio")
{
Expand Down Expand Up @@ -568,12 +556,6 @@ private void RegisterObservers(ControlledRuntime runtime)
// Always output a json log of the error
JsonLogger = new JsonWriter();
runtime.SetJsonLogger(JsonLogger);

if (_conflictOpObserver != null)
{
_conflictOpObserver.VectorClockGenerator = JsonLogger.VcGenerator;
runtime.RegisterLog(_conflictOpObserver);
}
}

/// <summary>
Expand Down Expand Up @@ -716,7 +698,6 @@ private void RunNextIteration(int schedule)

runtimeLogger?.Dispose();
runtime?.Dispose();
_conflictOpObserver?.Reset();
}
}

Expand Down
Loading
Loading