Skip to content

Commit 84ed22e

Browse files
committed
Fix runtime profile evidence source
1 parent dd35a49 commit 84ed22e

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

benchmark-runtime/src/main/java/com/loohp/interactionvisualizer/benchmark/runtime/RuntimeComparisonPlugin.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ private boolean setup(CommandSender sender, String[] args) {
165165
}
166166

167167
private boolean start(CommandSender sender, String[] args) {
168-
if (args.length != 3) {
169-
sender.sendMessage("Usage: /ivcompare start <label> <A|B>");
168+
if (args.length != 4) {
169+
sender.sendMessage("Usage: /ivcompare start <label> <A|B> <legacy-parity|optimized-candidate>");
170170
return true;
171171
}
172172
if (collecting) {
@@ -187,7 +187,8 @@ private boolean start(CommandSender sender, String[] args) {
187187
}
188188
label = sanitize(args[1]);
189189
variant = requestedVariant;
190-
requestedFlags = readRequestedFlags(target);
190+
String runtimeProfile = args[3].toLowerCase(Locale.ROOT);
191+
requestedFlags = requestedFlagsForProfile(runtimeProfile);
191192
effectiveFlags = inspectEffectiveFlags(target.getClass());
192193
assertOptimizationProfile(variant, requestedFlags, effectiveFlags);
193194
tickSamples = 0;
@@ -196,7 +197,10 @@ private boolean start(CommandSender sender, String[] args) {
196197
startedNanos = System.nanoTime();
197198
skipNextTickSample = true;
198199
collecting = true;
199-
String record = "IV_COMPARE_START label=" + label + " variant=" + variant;
200+
String record = "IV_COMPARE_START label=" + label + " variant=" + variant
201+
+ " runtimeProfile=" + runtimeProfile
202+
+ " requestedPacketOnlyStatic=" + requestedFlags.packetOnlyStatic()
203+
+ " requestedEventDrivenBlockUpdates=" + requestedFlags.eventDrivenBlockUpdates();
200204
getLogger().info(record);
201205
sender.sendMessage(record);
202206
return true;
@@ -459,15 +463,13 @@ private static String sanitize(String value) {
459463
return sanitized.substring(0, Math.min(64, sanitized.length()));
460464
}
461465

462-
static RequestedFlags readRequestedFlags(Plugin target) {
463-
if (!(target instanceof JavaPlugin javaPlugin)) {
464-
throw new IllegalStateException("InteractionVisualizer target is not a JavaPlugin");
465-
}
466-
return new RequestedFlags(
467-
javaPlugin.getConfig().getBoolean(
468-
"Settings.Performance.VirtualItems.PacketOnlyStatic"),
469-
javaPlugin.getConfig().getBoolean(
470-
"Settings.Performance.BlockUpdates.EventDriven"));
466+
static RequestedFlags requestedFlagsForProfile(String runtimeProfile) {
467+
return switch (runtimeProfile) {
468+
case "legacy-parity" -> RequestedFlags.disabled();
469+
case "optimized-candidate" -> new RequestedFlags(true, true);
470+
default -> throw new IllegalArgumentException(
471+
"runtime profile must be legacy-parity or optimized-candidate");
472+
};
471473
}
472474

473475
static EffectiveFlags inspectEffectiveFlags(Class<?> targetClass) {

common/src/test/java/com/loohp/interactionvisualizer/benchmark/runtime/RuntimeComparisonPluginTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222

2323
class RuntimeComparisonPluginTest {
2424

25+
@Test
26+
void requestedFlagsComeFromTheControlledRuntimeProfile() {
27+
assertEquals(
28+
new RuntimeComparisonPlugin.RequestedFlags(false, false),
29+
RuntimeComparisonPlugin.requestedFlagsForProfile("legacy-parity"));
30+
assertEquals(
31+
new RuntimeComparisonPlugin.RequestedFlags(true, true),
32+
RuntimeComparisonPlugin.requestedFlagsForProfile("optimized-candidate"));
33+
assertThrows(IllegalArgumentException.class,
34+
() -> RuntimeComparisonPlugin.requestedFlagsForProfile("unknown"));
35+
}
36+
2537
@Test
2638
void legacyTargetIsRecordedAsUnsupported() {
2739
RuntimeComparisonPlugin.EffectiveFlags flags =

tools/perf/run-upstream-runtime-once.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ fi
489489
assert_client_alive
490490
send_console "ivcompare status"
491491
wait_for_log "IV_COMPARE_STATUS collecting=false scenario=$scenario expected=$scene_size actual=$scene_size player=IVBench targetEnabled=true activeFurnaces=$expected_active_furnaces" 30
492-
send_console "ivcompare start $run_id $variant"
493-
wait_for_log "IV_COMPARE_START label=$run_id variant=$variant" 30
492+
send_console "ivcompare start $run_id $variant $runtime_profile"
493+
wait_for_log "IV_COMPARE_START label=$run_id variant=$variant runtimeProfile=$runtime_profile" 30
494494
sleep "$measure_seconds"
495495
send_console "ivcompare stop"
496496
wait_for_log "IV_COMPARE {\"schemaVersion\":1,\"label\":\"$run_id\"" 60

0 commit comments

Comments
 (0)