From 08f5950e9fb79e5028776ba7fc9712a38287ad00 Mon Sep 17 00:00:00 2001 From: Louis Gesbert Date: Thu, 18 Mar 2021 17:55:49 +0100 Subject: [PATCH] Now reasonably fast :) --- src/client/opamClient.ml | 13 ++++++++++--- src/solver/opamSolver.ml | 34 +++++++++++++--------------------- tests/reftests/dune.inc | 12 ++++++++---- tests/reftests/gen.ml | 3 ++- tests/reftests/init.test | 9 +++------ 5 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/client/opamClient.ml b/src/client/opamClient.ml index 8f8f8957f74..37c970c5c08 100644 --- a/src/client/opamClient.ml +++ b/src/client/opamClient.ml @@ -896,6 +896,7 @@ let init "Initial download of repository failed."); let default_compiler = if dontswitch then [] else + let chrono = OpamConsole.timer () in let alternatives = OpamFormula.to_dnf (OpamFile.InitConfig.default_compiler init_config) @@ -907,10 +908,16 @@ let init ~requested:OpamPackage.Name.Set.empty Query in let univ = { univ with u_invariant = invariant } in - OpamStd.List.find_opt - (OpamSolver.atom_coinstallability_check univ) + let default_compiler = + OpamStd.List.find_opt + (OpamSolver.atom_coinstallability_check univ) alternatives - |> OpamStd.Option.default [] + |> OpamStd.Option.default [] + in + log "Selected default compiler %s in %0.3fs" + (OpamFormula.string_of_atoms default_compiler) + (chrono ()); + default_compiler in gt, OpamRepositoryState.unlock ~cleanup:false rt, default_compiler with e -> diff --git a/src/solver/opamSolver.ml b/src/solver/opamSolver.ml index 712192265ce..3cc1ff8e9e6 100644 --- a/src/solver/opamSolver.ml +++ b/src/solver/opamSolver.ml @@ -634,29 +634,21 @@ let check_for_conflicts universe = coinstallability_check universe universe.u_installed let atom_coinstallability_check universe atoms = - let packages = OpamFormula.packages_of_atoms universe.u_available atoms in - let map = OpamPackage.to_map packages in - List.for_all (fun (n, _) -> OpamPackage.Name.Map.mem n map) atoms && let version_map = cudf_versions_map universe universe.u_packages in + let check_pkg = { + Cudf.default_package with + package = "=check_coinstallability"; + depends = List.map (fun at -> [atom2cudf () version_map at]) atoms; + } in let cudf_universe = - load_cudf_universe ~build:true ~post:true ~version_map ~add_invariant:true - universe universe.u_packages () - in - let cudf_ll = - OpamPackage.Name.Map.fold (fun n versions acc -> - let packages = - OpamPackage.Version.Set.fold - (fun v -> OpamPackage.(Set.add (create n v))) - versions OpamPackage.Set.empty - in - opam2cudf - universe ~depopts:false ~build:true ~post:true version_map - packages - :: acc) - map [] - in - let result = Algo.Depsolver.edos_coinstall_prod cudf_universe cudf_ll in - List.exists Algo.Diagnostic.is_solution result + Cudf.load_universe + (check_pkg :: + opam_invariant_package version_map universe.u_invariant :: + opam2cudf universe version_map universe.u_available + ~depopts:false ~build:true ~post:true) + in + Algo.Depsolver.edos_install cudf_universe check_pkg + |> Algo.Diagnostic.is_solution let new_packages sol = OpamCudf.ActionGraph.fold_vertex (fun action packages -> diff --git a/tests/reftests/dune.inc b/tests/reftests/dune.inc index 1c673bd7f17..2c3f9bf05df 100644 --- a/tests/reftests/dune.inc +++ b/tests/reftests/dune.inc @@ -238,9 +238,10 @@ (targets root-009e00fa) (action (progn + (ignore-stdout (run %{bin:opam} init --root=%{targets} --no-setup --bypass-checks --no-opamrc --bare - file://%{dep:opam-repo-009e00fa})))) + file://%{dep:opam-repo-009e00fa}))))) (rule (targets opam-archive-632bc2e.tar.gz) @@ -257,9 +258,10 @@ (targets root-632bc2e) (action (progn + (ignore-stdout (run %{bin:opam} init --root=%{targets} --no-setup --bypass-checks --no-opamrc --bare - file://%{dep:opam-repo-632bc2e})))) + file://%{dep:opam-repo-632bc2e}))))) (rule (targets opam-archive-c1d23f0e.tar.gz) @@ -276,9 +278,10 @@ (targets root-c1d23f0e) (action (progn + (ignore-stdout (run %{bin:opam} init --root=%{targets} --no-setup --bypass-checks --no-opamrc --bare - file://%{dep:opam-repo-c1d23f0e})))) + file://%{dep:opam-repo-c1d23f0e}))))) (rule (targets opam-archive-f372039d.tar.gz) @@ -295,6 +298,7 @@ (targets root-f372039d) (action (progn + (ignore-stdout (run %{bin:opam} init --root=%{targets} --no-setup --bypass-checks --no-opamrc --bare - file://%{dep:opam-repo-f372039d})))) + file://%{dep:opam-repo-f372039d}))))) diff --git a/tests/reftests/gen.ml b/tests/reftests/gen.ml index cff2d84e626..52581665657 100644 --- a/tests/reftests/gen.ml +++ b/tests/reftests/gen.ml @@ -61,9 +61,10 @@ let opam_init_rule archive_hash = (targets %s) (action (progn + (ignore-stdout (run %%{bin:opam} init --root=%%{targets} --no-setup --bypass-checks --no-opamrc --bare - file://%%{dep:%s})))) + file://%%{dep:%s}))))) |} (opamroot_directory ~archive_hash) (repo_directory ~archive_hash) module StringSet = Set.Make(String) diff --git a/tests/reftests/init.test b/tests/reftests/init.test index 8e40df416bc..3bae6ea3287 100644 --- a/tests/reftests/init.test +++ b/tests/reftests/init.test @@ -3,9 +3,8 @@ ### tar xzf ${OPAMROOT}/repo/default.tar.gz ### rm -rf ${OPAMROOT} ### OPAMVAR_sys_ocaml_version='' -### opam init --no-setup default default/ --fake +### opam init --no-setup --bypass-checks default default/ --fake No configuration file found, using built-in defaults. -Checking for available remotes: rsync and local, git, mercurial, darcs. Perfect! <><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><> [default] Initialised @@ -35,9 +34,8 @@ Done. ["ocaml" {>= "4.05.0"}] ### rm -rf ${OPAMROOT} ### OPAMVAR_sys_ocaml_version=4.02.3 -### opam init --no-setup default default/ --fake +### opam init --no-setup --bypass-checks default default/ --fake No configuration file found, using built-in defaults. -Checking for available remotes: rsync and local, git, mercurial, darcs. Perfect! <><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><> [default] Initialised @@ -67,9 +65,8 @@ Done. ["ocaml" {>= "4.05.0"}] ### rm -rf ${OPAMROOT} ### OPAMVAR_sys_ocaml_version=4.07.0 -### opam init --no-setup default default/ --fake +### opam init --no-setup --bypass-checks default default/ --fake No configuration file found, using built-in defaults. -Checking for available remotes: rsync and local, git, mercurial, darcs. Perfect! <><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><> [default] Initialised