Skip to content

Commit 230f547

Browse files
committed
Fix A-B config generation for enabled defaults
1 parent 0c604dd commit 230f547

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ unzip -p "$plugin_jar" config.yml > "$run_directory/plugins/InteractionVisualize
185185

186186
python3 - "$run_directory/plugins/InteractionVisualizer/config.yml" "$scenario" "$variant" "$ab_factor" <<'PY'
187187
from pathlib import Path
188+
import re
188189
import sys
189190
190191
path = Path(sys.argv[1])
@@ -200,20 +201,26 @@ def replace_once(old: str, new: str) -> None:
200201
raise SystemExit(f"Expected one config token {old!r}, found {count}")
201202
text = text.replace(old, new, 1)
202203
204+
def replace_boolean_once(prefix: str, value: bool) -> None:
205+
global text
206+
pattern = re.compile(rf"(?m)^{re.escape(prefix)}(?:true|false)$")
207+
replacement = f"{prefix}{str(value).lower()}"
208+
text, count = pattern.subn(replacement, text, count=1)
209+
if count != 1:
210+
raise SystemExit(
211+
f"Expected one boolean config token with prefix {prefix!r}, found {count}"
212+
)
213+
203214
packet_only = scenario == "visibility-return" or (
204215
scenario in {"static-steady", "static-spawn"} and variant == "B"
205216
)
206217
visibility_limit = scenario.startswith("visibility-") and variant == "B"
207218
event_driven = scenario.startswith("block-") and (
208219
ab_factor == "legacy-text-component-cache" or variant == "B"
209220
)
210-
replace_once(" PacketOnlyStatic: false",
211-
f" PacketOnlyStatic: {str(packet_only).lower()}")
212-
replace_once(" Enabled: false\n BucketSize: 128\n RestorePerTick: 32",
213-
f" Enabled: {str(visibility_limit).lower()}\n"
214-
" BucketSize: 128\n RestorePerTick: 32")
215-
replace_once(" EventDriven: false",
216-
f" EventDriven: {str(event_driven).lower()}")
221+
replace_boolean_once(" PacketOnlyStatic: ", packet_only)
222+
replace_boolean_once(" Enabled: ", visibility_limit)
223+
replace_boolean_once(" EventDriven: ", event_driven)
217224
replace_once(" Updater: true", " Updater: false")
218225
replace_once(" DownloadLanguageFiles: true", " DownloadLanguageFiles: false")
219226
path.write_text(text, encoding="utf-8", newline="\n")

0 commit comments

Comments
 (0)