Skip to content

Commit

Permalink
Let the solver timeout be configurable on the command-line
Browse files Browse the repository at this point in the history
Requested by #685
  • Loading branch information
samoht committed Jul 16, 2013
1 parent 83019d4 commit 965fb99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/core/opamGlobals.ml
Expand Up @@ -53,7 +53,15 @@ let download_retry =
try max 1 (int_of_string (OpamMisc.getenv "OPAMRETRY"))
with _ -> 10

let cudf_file = ref (None: string option)
let cudf_file = ref (
try Some (OpamMisc.getenv "OPAMCUDFFILE")
with _ -> None
)

let solver_timeout =
try float_of_string (OpamMisc.getenv "OPAMSOLVERTIMEOUT")
with _ -> 5.

let aspcud_criteria =
try OpamMisc.strip (OpamMisc.getenv "OPAMCRITERIA")
with _ -> "-removed,-notuptodate,-new"
Expand Down
7 changes: 2 additions & 5 deletions src/solver/opamHeuristic.ml
Expand Up @@ -99,9 +99,6 @@ let succ ~bounds l =
let k = List.fold_left (+) 0 l in
init ~bounds (k+1)

(* Maximum duration of the state-space exploration. *)
let exploration_timeout = 5.

let fallback_msg =
"You might need to add explicit version constraints to your \
request to get a better answer.\n"
Expand Down Expand Up @@ -145,10 +142,10 @@ let brute_force ?(verbose=true) is_consistent state_space =
let t1 = Unix.time () in
if verbose && !count mod interval = interval - 1 then
OpamGlobals.msg ".";
if t1 -. t0 > exploration_timeout then (
if t1 -. t0 > OpamGlobals.solver_timeout then (
OpamGlobals.msg
"The brute-force exploration algorithm timed-out [%d states, %.2gs].\n%s\n"
!count exploration_timeout fallback_msg;
!count OpamGlobals.solver_timeout fallback_msg;
None
) else
if is_consistent state then
Expand Down

0 comments on commit 965fb99

Please sign in to comment.