Skip to content

Commit

Permalink
fix backing store bug on activity def cycles, remove too-early log init
Browse files Browse the repository at this point in the history
  • Loading branch information
jshook committed Oct 6, 2023
1 parent 01cdad0 commit b1cc0b2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ public <U> Sequence<U> transform(Function<T, U> func) {

@Override
public String toString() {
return Arrays.toString(this.seq);
return "seq len="+seq.length + ", LUT=" + Arrays.toString(this.seq);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,15 @@ public synchronized void setDefaultsFromOpSequence(OpSequence<?> seq) {
getParams().setSilently("stride", stride);
}

// CYCLES
Optional<String> cyclesOpt = getParams().getOptionalString("cycles");
if (cyclesOpt.isEmpty()) {
String cycles = getParams().getOptionalString("stride").orElseThrow();
logger.info(() -> "defaulting cycles to " + cycles + " (the stride length)");
// getParams().set("cycles", getParams().getOptionalString("stride").orElseThrow());
getParams().setSilently("cycles", getParams().getOptionalString("stride").orElseThrow());
// getParams().setSilently("cycles", getParams().getOptionalString("stride").orElseThrow());
this.getActivityDef().setCycles(getParams().getOptionalString("stride").orElseThrow());
// getParams().set("cycles", getParams().getOptionalString("stride").orElseThrow());
} else {
if (0 == activityDef.getCycleCount()) {
throw new RuntimeException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,15 @@ public void onActivityDefUpdate(ActivityDef activityDef) {

cycles_max.set(cyclesSpec.last_exclusive());
if (cycles_min.get() != cyclesSpec.first_inclusive()) {
logger.info(() -> "resetting cycle value to new start: cycle[" + cycles_min.get() + "->" + cyclesSpec.first_inclusive() + "] " +
logger.info(() -> "resetting first cycle (inclusive) value to: cycle[" + cycles_min.get() + "->" + cyclesSpec.first_inclusive() + "] " +
" start[" + cycle_value.get() + "->" + cycles_min.get() + "]");
cycles_min.set(cyclesSpec.first_inclusive());
cycle_value.set(cycles_min.get());
}
if (cycles_max.get() != cyclesSpec.last_exclusive()) {
logger.info(() -> "resetting last cycle (exclusive) value to: cycle[" + cycles_max.get() + "->" + cyclesSpec.last_exclusive() + "]");
cycles_max.set(cyclesSpec.last_exclusive());
}

recycles_max.set(recyclesSpec.last_exclusive());
if (recycles_min.get() != recyclesSpec.first_inclusive()) {
Expand All @@ -131,6 +135,11 @@ public void onActivityDefUpdate(ActivityDef activityDef) {
recycles_min.set(recyclesSpec.first_inclusive());
recycle_value.set(recyclesSpec.first_inclusive());
}
if (recycles_max.get() != recyclesSpec.last_exclusive()) {
logger.info(() -> "resetting last recycle (exclusive) value to: recycle[" + recycles_max.get() + "->" + recyclesSpec.last_exclusive() + "]");
recycles_max.set(recyclesSpec.last_exclusive());
}

}

public long getStartedAtMillis() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ public void testThatRadixStackingIsAccurate() {
assertThat(segment).isNull();
}

@Test
public void testThatOneCycleAndOneRecycleYieldsOneTotal() {
AtomicInput input = new AtomicInput(root, ActivityDef.parseActivityDef("alias=foo;cycles=1;recycles=1"));
CycleSegment segment = input.getInputSegment(1);
assertThat(segment).isNotNull();
assertThat(segment.nextCycle()).isEqualTo(0L);
}
@Test
public void testThatCycleAndRecycleOffsetsWork() {
AtomicInput input = new AtomicInput(root, ActivityDef.parseActivityDef("alias=foo;cycles=310..330;recycles=37..39"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ public void setSilently(String paramName, Object newValue) {


public void set(String paramName, Object newValue) {
if (paramName.equals("cycles")) {
logger.warn("Setting 'cycles' on the parameter map is likely causing a bug in your activity. Call setCycles on the def instead.");
}
super.put(paramName, String.valueOf(newValue));
logger.info(() -> "setting param " + paramName + "=" + newValue);
markMutation();
Expand Down
8 changes: 4 additions & 4 deletions nb-api/src/main/java/io/nosqlbench/api/labels/MapLabels.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class MapLabels implements NBLabels {

private final static Logger logger = LogManager.getLogger(MapLabels.class);
// private final static Logger logger = LogManager.getLogger(MapLabels.class);
private final Map<String,String> labels;

public MapLabels(final Map<String, String> labels) {
Expand Down Expand Up @@ -147,9 +147,9 @@ public static String sanitize(String word) {
sanitized = sanitized.replaceAll("-", "_");
sanitized = sanitized.replaceAll("[^a-zA-Z0-9_]+", "");

if (!word.equals(sanitized)) {
logger.warn("The identifier or value '" + word + "' was sanitized to '" + sanitized + "' to be compatible with monitoring systems. You should probably change this to make diagnostics easier.");
}
// if (!word.equals(sanitized)) {
// logger.warn("The identifier or value '" + word + "' was sanitized to '" + sanitized + "' to be compatible with monitoring systems. You should probably change this to make diagnostics easier.");
// }
return sanitized;
}

Expand Down

0 comments on commit b1cc0b2

Please sign in to comment.