Skip to content

Commit ef937fd

Browse files
feat(tools): thread sketch_parameters, rsync init_sql_file, add clickhouse_image_tag (#553)
- Pass optional sketch_parameters through from experiment config into the generated SQL planner input YAML. - Rsync init_sql_file to the remote node before executing it, instead of assuming it's already present there. - Allow overriding the ClickHouse image tag via dataset.clickhouse_image_tag (pre-AVX2 CPUs SIGILL on "latest"). Split out of #514. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 6cec5fc commit ef937fd

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

asap-tools/experiments/experiment_run_clickhouse.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
import json
9494
import os
9595
import time
96+
from typing import Optional
9697
from urllib.parse import urlparse
9798

9899
import hydra
@@ -168,7 +169,7 @@ def _run_query_workload(
168169
remote_monitor_service: RemoteMonitorService,
169170
minimum_experiment_running_time: int,
170171
manual_remote_monitor: bool,
171-
query_engine_service: QueryEngineRustService | None,
172+
query_engine_service: Optional[QueryEngineRustService],
172173
profile_query_engine: bool,
173174
profile_prometheus_time,
174175
) -> None:
@@ -306,6 +307,9 @@ def main(cfg: DictConfig) -> None:
306307
local_experiment_dir=local_experiment_root_dir,
307308
http_port=clickhouse_http_port,
308309
database=CLICKHOUSE_DATABASE,
310+
# Pre-AVX2 CPUs (e.g. Sandy/Ivy Bridge CloudLab nodes) SIGILL on the
311+
# "latest" image; override via dataset.clickhouse_image_tag if needed.
312+
image_tag=dataset_cfg.get("clickhouse_image_tag", "latest"),
309313
)
310314

311315
# --- load data once before the mode loop (DROP + reload) ---
@@ -373,7 +377,7 @@ def main(cfg: DictConfig) -> None:
373377

374378
# Generate and rsync the planner input config to the node
375379
planner_input_yaml = config.generate_sql_planner_input(
376-
ep.query_groups, dataset_cfg
380+
ep.query_groups, dataset_cfg, cfg.get("sketch_parameters", None)
377381
)
378382
local_planner_input = os.path.join(
379383
local_controller_dir, "planner_input.yaml"

asap-tools/experiments/experiment_utils/config.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,13 +827,19 @@ def generate_clickhouse_client_configs(
827827
return modes
828828

829829

830-
def generate_sql_planner_input(query_groups: Any, dataset_cfg: Any) -> str:
830+
def generate_sql_planner_input(
831+
query_groups: Any, dataset_cfg: Any, sketch_parameters: Any = None
832+
) -> str:
831833
"""Generate the YAML input file for asap-planner in SQL mode.
832834
833835
The planner (``asap-planner --query-language sql``) reads a
834836
``SQLControllerConfig`` YAML that contains:
835837
- ``tables``: schema of the tables being queried
836838
- ``query_groups``: SQL queries with controller options
839+
- ``sketch_parameters``: optional per-sketch-type overrides (e.g.
840+
``DatasketchesKLL.K``), matching ``ControllerConfig``'s PromQL-mode
841+
field of the same name (``SketchParameterOverrides`` in
842+
asap-planner-rs's ``config/input.rs``).
837843
838844
This function builds that YAML from the experiment config so the runner
839845
does not need a hand-authored planner input file.
@@ -844,6 +850,10 @@ def generate_sql_planner_input(query_groups: Any, dataset_cfg: Any) -> str:
844850
``controller_options`` (``accuracy_sla``, ``latency_sla``).
845851
dataset_cfg: DictConfig with ``table``/``name``, and ``precompute``
846852
sub-config (``timestamp_col``, ``value_col``, ``label_cols``).
853+
sketch_parameters: Optional DictConfig/dict mirroring ``config.yaml``'s
854+
top-level ``sketch_parameters`` section (``CountMinSketch``,
855+
``DatasketchesKLL``, etc.). When ``None``, the planner falls back
856+
to its own defaults.
847857
848858
Returns:
849859
YAML string ready to write to disk and pass to asap-planner.
@@ -899,6 +909,10 @@ def generate_sql_planner_input(query_groups: Any, dataset_cfg: Any) -> str:
899909
"query_groups": planner_query_groups,
900910
"aggregate_cleanup": {"policy": "read_based"},
901911
}
912+
if sketch_parameters is not None:
913+
if isinstance(sketch_parameters, (DictConfig, ListConfig)):
914+
sketch_parameters = OmegaConf.to_container(sketch_parameters, resolve=True)
915+
planner_input["sketch_parameters"] = sketch_parameters
902916
return yaml.dump(planner_input, default_flow_style=False, allow_unicode=True)
903917

904918

asap-tools/experiments/experiment_utils/services/clickhouse_service.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,9 @@ def start(
268268
table: Target table name. Defaults to the dataset's standard table
269269
(``hits`` for clickbench, ``h2o_groupby`` for h2o).
270270
batch_size: INSERT batch size for H2O loading (default 50 000).
271-
init_sql_file: Path to a DDL SQL file *already on the remote node*.
272-
When ``None``, the built-in ``*_init.sql`` is rsynced and used.
271+
init_sql_file: Path to a local DDL SQL file; rsynced to the remote
272+
node and executed. When ``None``, the built-in ``*_init.sql``
273+
is rsynced and used instead.
273274
max_rows: Maximum rows to load (0 = all).
274275
"""
275276
if remote_data_file is None:
@@ -292,7 +293,12 @@ def start(
292293

293294
if init_sql_file is not None:
294295
print(f"Running init SQL from {init_sql_file!r}...")
295-
self._exec_sql_file(init_sql_file, url)
296+
remote_ddl = f"/tmp/{dataset_name}_init_{os.getpid()}.sql"
297+
self._rsync_to_remote(init_sql_file, remote_ddl)
298+
try:
299+
self._exec_sql_file(remote_ddl, url)
300+
finally:
301+
self._remote_rm(remote_ddl)
296302
elif dataset_name in self.BUILTIN_DDL_FILES:
297303
local_ddl = os.path.join(
298304
self._ASSETS_DIR, self.BUILTIN_DDL_FILES[dataset_name]

0 commit comments

Comments
 (0)