Skip to content

Commit

Permalink
removed prefix from time_query()
Browse files Browse the repository at this point in the history
  • Loading branch information
wangpatrick57 committed Nov 14, 2024
1 parent e84af18 commit 875ad1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 8 additions & 3 deletions env/pg_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@ def move_log(self) -> None:
self.log_step += 1

def time_query(
self, prefix: str, query: str, timeout: float
self, query: str, timeout: float
) -> tuple[float, bool, Any]:
"""
Run a query with a timeout. If you want to attach per-query knobs, attach them to the query string itself.
It returns the runtime, whether the query timed out, and the explain data.
"""
did_time_out = False
has_explain = "EXPLAIN" in query
explain_data = None
Expand All @@ -118,12 +123,12 @@ def time_query(
explain_data = c

logging.getLogger(DBGYM_LOGGER_NAME).debug(
f"{prefix} evaluated in {qid_runtime/1e6}"
f"{query} evaluated in {qid_runtime/1e6}"
)

except QueryCanceled:
logging.getLogger(DBGYM_LOGGER_NAME).debug(
f"{prefix} exceeded evaluation timeout {timeout}"
f"{query} exceeded evaluation timeout {timeout}"
)
qid_runtime = timeout * 1e6
did_time_out = True
Expand Down
4 changes: 1 addition & 3 deletions tune/protox/env/util/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def _force_statement_timeout(


def _acquire_metrics_around_query(
prefix: str,
pg_conn: PostgresConn,
query: str,
query_timeout: float = 0.0,
Expand All @@ -52,7 +51,7 @@ def _acquire_metrics_around_query(
), f'Setting query_timeout to 0 indicates "timeout". However, setting query_timeout ({query_timeout}) < 0 is a bug.'

qid_runtime, did_time_out, explain_data = pg_conn.time_query(
prefix, query, query_timeout
query, query_timeout
)

# Wipe the statement timeout.
Expand Down Expand Up @@ -108,7 +107,6 @@ def execute_variations(
)

runtime, did_time_out, explain_data, metric = _acquire_metrics_around_query(
prefix=qr.prefix_qid,
pg_conn=pg_conn,
query=pqk_query,
query_timeout=timeout_limit,
Expand Down

0 comments on commit 875ad1a

Please sign in to comment.