Skip to content

Commit

Permalink
[PEx] Cleanup disk tasks on exit, change defaults
Browse files Browse the repository at this point in the history
Cleanup tasks/ directory on exiting

Change default for schedules-per-task to 500

Change report wait time to 10 sec.
  • Loading branch information
aman-goel committed Jul 19, 2024
1 parent 9c84684 commit 0c4be9e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
1 change: 0 additions & 1 deletion Src/PRuntimes/PExplicitRuntime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pexplicit.runtime.logger.PExplicitLogger;
import pexplicit.runtime.logger.StatWriter;
import pexplicit.runtime.machine.PTestDriver;
import pexplicit.runtime.scheduler.explicit.strategy.SearchTask;
import pexplicit.utils.exceptions.BugFoundException;
import pexplicit.utils.monitor.MemoryMonitor;
import pexplicit.utils.monitor.TimeMonitor;
Expand All @@ -34,6 +35,7 @@ public static void main(String[] args) {
PExplicitGlobal.setConfig(PExplicitOptions.ParseCommandlineArgs(args));
PExplicitLogger.Initialize(PExplicitGlobal.getConfig().getVerbosity());
ComputeHash.Initialize();
SearchTask.Initialize();

// get reflections corresponding to the model
Reflections reflections = new Reflections("pexplicit.model");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pexplicit.runtime.logger.PExplicitLogger;
import pexplicit.runtime.logger.StatWriter;
import pexplicit.runtime.scheduler.explicit.ExplicitSearchScheduler;
import pexplicit.runtime.scheduler.explicit.strategy.SearchTask;
import pexplicit.runtime.scheduler.replay.ReplayScheduler;
import pexplicit.utils.exceptions.BugFoundException;
import pexplicit.utils.exceptions.MemoutException;
Expand Down Expand Up @@ -124,6 +125,7 @@ private static void process(boolean resume) throws Exception {
future.cancel(true);
executor.shutdownNow();
scheduler.updateResult();
SearchTask.Cleanup();
printStats();
PExplicitLogger.logEndOfRun(scheduler, Duration.between(TimeMonitor.getStart(), Instant.now()).getSeconds());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class PExplicitConfig {
SearchStrategyMode searchStrategyMode = SearchStrategyMode.Random;
// max number of schedules per search task
@Setter
int maxSchedulesPerTask = 10;
int maxSchedulesPerTask = 500;
//max number of children search tasks
@Setter
int maxChildrenPerTask = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ private void printProgressHeader(boolean consolePrint) {
}

protected void printProgress(boolean forcePrint) {
if (forcePrint || (TimeMonitor.findInterval(getLastReportTime()) > 5)) {
if (forcePrint || (TimeMonitor.findInterval(getLastReportTime()) > 10)) {
setLastReportTime(Instant.now());
double newRuntime = TimeMonitor.getRuntime();
printCurrentStatus(newRuntime);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pexplicit.runtime.scheduler.explicit.strategy;

import lombok.Getter;
import org.apache.commons.io.FileUtils;
import pexplicit.runtime.PExplicitGlobal;
import pexplicit.runtime.logger.PExplicitLogger;
import pexplicit.runtime.machine.PMachineId;
Expand Down Expand Up @@ -220,14 +221,31 @@ public void clearSearchUnit(int choiceNum) {
searchUnits.remove(choiceNum);
}

public static void Initialize() {
String taskPath = PExplicitGlobal.getConfig().getOutputFolder() + "/tasks/";
try {
Files.createDirectories(Paths.get(taskPath));
} catch (IOException e) {
throw new RuntimeException("Failed to initialize tasks at " + taskPath, e);
}
}

public static void Cleanup() {
String taskPath = PExplicitGlobal.getConfig().getOutputFolder() + "/tasks/";
try {
FileUtils.deleteDirectory(new File(taskPath));
} catch (IOException e) {
throw new RuntimeException("Failed to cleanup tasks at " + taskPath, e);
}
}

public void serializeTask() {
assert (serializeFile == null);
assert (prefixChoices != null);
assert (searchUnits != null);

serializeFile = PExplicitGlobal.getConfig().getOutputFolder() + "/tasks/" + this + ".ser";
try {
Files.createDirectories(Paths.get(PExplicitGlobal.getConfig().getOutputFolder() + "/tasks/"));
FileOutputStream fos = new FileOutputStream(serializeFile);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(this.prefixChoices);
Expand Down

0 comments on commit 0c4be9e

Please sign in to comment.