Skip to content

Commit

Permalink
[PEx] bump version, change cli defaults
Browse files Browse the repository at this point in the history
Change max choices per choose statement to 10 per call and 100 per schedule by default

Minor renaming
  • Loading branch information
aman-goel committed Sep 5, 2024
1 parent 9a38e68 commit e97c887
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Src/PCompiler/CompilerCore/Backend/PEx/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal class Constants
<dependency>
<groupId>io.github.p-org</groupId>
<artifactId>pex</artifactId>
<version>[0.0.1,)</version>
<version>[0.2.0,)</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
Expand Down
2 changes: 1 addition & 1 deletion Src/PRuntimes/PExRuntime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<log4j2.configurationFile>${project.basedir}/src/main/resources/log4j2.xml</log4j2.configurationFile>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.1.0</revision>
<revision>0.2.0</revision>
</properties>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public class PExConfig {
int maxChildrenPerTask = 2;
//max number of choices per choose(.) operation per call
@Setter
int maxChoiceBoundPerCall = 10000;
int maxChoicesPerStmtPerCall = 10;
//max number of choices per choose(.) operation in total
@Setter
int maxChoiceBoundTotal = 0;
int maxChoicesPerStmtPerSchedule = 100;
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public class PExOptions {
.build();
addHiddenOption(choiceSelect);

// max number of choices per choose(.) call
// max number of choices per choose(.) per call
Option maxChoicesPerCall =
Option.builder()
.longOpt("max-choices-per-call")
Expand All @@ -248,10 +248,10 @@ public class PExOptions {
.build();
addHiddenOption(maxChoicesPerCall);

// max number of choices in total
// max number of choices per choose(.) per schedule
Option maxChoicesTotal =
Option.builder()
.longOpt("max-choices-total")
.longOpt("max-choices-per-schedule")
.desc("Max number of choices allowed per choose statement in total (default: no bound)")
.numberOfArgs(1)
.hasArg()
Expand Down Expand Up @@ -494,15 +494,15 @@ public static PExConfig ParseCommandlineArgs(String[] args) {
}
case "max-choices-per-call":
try {
config.setMaxChoiceBoundPerCall(Integer.parseInt(option.getValue()));
config.setMaxChoicesPerStmtPerCall(Integer.parseInt(option.getValue()));
} catch (NumberFormatException ex) {
optionError(
option, String.format("Expected an integer value, got %s", option.getValue()));
}
break;
case "max-choices-total":
case "max-choices-per-schedule":
try {
config.setMaxChoiceBoundTotal(Integer.parseInt(option.getValue()));
config.setMaxChoicesPerStmtPerSchedule(Integer.parseInt(option.getValue()));
} catch (NumberFormatException ex) {
optionError(
option, String.format("Expected an integer value, got %s", option.getValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ public void updateChoiceStats(String loc, int num) {
choicesNumCalls.put(loc, choicesNumCalls.get(loc) + 1);
choicesNumChoices.put(loc, choicesNumChoices.get(loc) + num);
}
if (PExGlobal.getConfig().getMaxChoiceBoundPerCall() > 0 && num > PExGlobal.getConfig().getMaxChoiceBoundPerCall()) {
if (PExGlobal.getConfig().getMaxChoicesPerStmtPerCall() > 0 && num > PExGlobal.getConfig().getMaxChoicesPerStmtPerCall()) {
throw new TooManyChoicesException(loc, num);
}
if (PExGlobal.getConfig().getMaxChoiceBoundTotal() > 0 && choicesNumChoices.get(loc) > PExGlobal.getConfig().getMaxChoiceBoundTotal()) {
if (PExGlobal.getConfig().getMaxChoicesPerStmtPerSchedule() > 0 && choicesNumChoices.get(loc) > PExGlobal.getConfig().getMaxChoicesPerStmtPerSchedule()) {
throw new TooManyChoicesException(loc, choicesNumChoices.get(loc), choicesNumCalls.get(loc));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TooManyChoicesException extends BugFoundException {
*/
public TooManyChoicesException(String loc, int numChoices) {
super(String.format("%s: choose expects a parameter with at most %d choices, got %d choices instead.",
loc, PExGlobal.getConfig().getMaxChoiceBoundPerCall(), numChoices));
loc, PExGlobal.getConfig().getMaxChoicesPerStmtPerCall(), numChoices));
}

/**
Expand All @@ -26,6 +26,6 @@ public TooManyChoicesException(String loc, int numChoices, int numCalls) {
%s: too many choices generated from this location - total %d choices after %d choose calls.
Reduce the total number of choices generated here to at most %d, by reducing the number times this choose statement is called.
For example, limit the number of transactions/requests etc.""",
loc, numChoices, numCalls, PExGlobal.getConfig().getMaxChoiceBoundTotal()));
loc, numChoices, numCalls, PExGlobal.getConfig().getMaxChoicesPerStmtPerSchedule()));
}
}

0 comments on commit e97c887

Please sign in to comment.