Skip to content

Commit 599880b

Browse files
authored
Ensure data_collector.DEADLINE_IN_SECONDS is higher than compilation_runner.COMPILATION_TIMEOUT (#232)
This also removes the currently unused `compilation_timeout` parameter from the CompilationRunner constructor to avoid discrepancies.
1 parent 6d9b2ae commit 599880b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

compiler_opt/rl/compilation_runner.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from compiler_opt.rl import corpus
3535
from compiler_opt.rl import policy_saver
3636

37-
_COMPILATION_TIMEOUT = flags.DEFINE_integer(
37+
COMPILATION_TIMEOUT = flags.DEFINE_integer(
3838
'compilation_timeout', 60,
3939
'Max duration (in seconds) after which we cancel any compilation job.')
4040
_QUIET = flags.DEFINE_bool(
@@ -341,7 +341,6 @@ def __init__(self,
341341
clang_path: Optional[str] = None,
342342
launcher_path: Optional[str] = None,
343343
moving_average_decay_rate: float = 1,
344-
compilation_timeout=None,
345344
create_observer_fns: Optional[List[Callable[
346345
[], CompilationResultObserver]]] = None):
347346
"""Initialization of CompilationRunner class.
@@ -361,8 +360,7 @@ def __init__(self,
361360
self._launcher_path = launcher_path
362361
self._moving_average_decay_rate = moving_average_decay_rate
363362
# Avoid reading the flag during the first interpretation of this module.
364-
self._compilation_timeout = (
365-
compilation_timeout or _COMPILATION_TIMEOUT.value)
363+
self._compilation_timeout = COMPILATION_TIMEOUT.value
366364
self._cancellation_manager = WorkerCancellationManager()
367365
self._observers = ([f() for f in create_observer_fns]
368366
if create_observer_fns else [])

compiler_opt/rl/data_collector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020

2121
import numpy as np
2222
from compiler_opt.rl import policy_saver
23+
from compiler_opt.rl.compilation_runner import COMPILATION_TIMEOUT
2324
from tf_agents.trajectories import trajectory
2425

2526
# Deadline for data collection.
26-
DEADLINE_IN_SECONDS = 30
27+
DEADLINE_IN_SECONDS = int(COMPILATION_TIMEOUT.value * 1.2)
2728

2829
# We don't wait for all data collection to finish --- it continues if either of
2930
# the wait_termination_conditions is met.

0 commit comments

Comments
 (0)