-
Notifications
You must be signed in to change notification settings - Fork 342
dependencies.cpp optimizations #1891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2b0d029
Remove obsolete code
dg0yt 89c10e0
Unroll dep_to_spec
dg0yt 940b57a
Remove unused variable
dg0yt de2275d
else { if ... } -> else if ...
dg0yt 0cb6c37
Batch and load the complete current frame
dg0yt d66d82e
Use evaluate()
dg0yt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1465,7 +1465,7 @@ namespace vcpkg | |
| void require_port_defaults(PackageNode& ref, const std::string& origin); | ||
|
|
||
| void resolve_stack(const ConstraintFrame& frame); | ||
| const CMakeVars::CMakeVars& batch_load_vars(const PackageSpec& spec); | ||
| const CMakeVars::CMakeVars& batch_load_vars(const ConstraintFrame& frame); | ||
|
|
||
| Optional<const PackageNode&> find_package(const PackageSpec& spec) const; | ||
|
|
||
|
|
@@ -1485,13 +1485,15 @@ namespace vcpkg | |
| std::vector<LocalizedString> m_errors; | ||
| }; | ||
|
|
||
| const CMakeVars::CMakeVars& VersionedPackageGraph::batch_load_vars(const PackageSpec& spec) | ||
| const CMakeVars::CMakeVars& VersionedPackageGraph::batch_load_vars(const ConstraintFrame& frame) | ||
| { | ||
| auto vars = m_var_provider.get_dep_info_vars(spec); | ||
| auto vars = m_var_provider.get_dep_info_vars(frame.spec); | ||
| if (!vars) | ||
| { | ||
| // We want to batch as many dep_infos as possible, so look ahead in the stack | ||
| std::unordered_set<PackageSpec> spec_set = {spec}; | ||
| // We want to batch as many dep_infos as possible, so look ahead in the frame and stack | ||
| std::unordered_set<PackageSpec> spec_set = {frame.spec}; | ||
| for (auto&& d : frame.deps) | ||
| spec_set.emplace(d.name, d.host ? m_host_triplet : frame.spec.triplet()); | ||
| for (auto&& s : m_resolve_stack) | ||
| { | ||
| spec_set.insert(s.spec); | ||
|
|
@@ -1500,7 +1502,7 @@ namespace vcpkg | |
| } | ||
| std::vector<PackageSpec> spec_vec(spec_set.begin(), spec_set.end()); | ||
| m_var_provider.load_dep_info_vars(spec_vec, m_host_triplet); | ||
| return m_var_provider.get_dep_info_vars(spec).value_or_exit(VCPKG_LINE_INFO); | ||
| return m_var_provider.get_dep_info_vars(frame.spec).value_or_exit(VCPKG_LINE_INFO); | ||
| } | ||
| return *vars.get(); | ||
| } | ||
|
|
@@ -1509,7 +1511,7 @@ namespace vcpkg | |
| { | ||
| for (auto&& dep : frame.deps) | ||
| { | ||
| if (!dep.platform.is_empty() && !dep.platform.evaluate(batch_load_vars(frame.spec))) continue; | ||
| if (!dep.platform.is_empty() && !dep.platform.evaluate(batch_load_vars(frame))) continue; | ||
|
|
||
| PackageSpec dep_spec(dep.name, dep.host ? m_host_triplet : frame.spec.triplet()); | ||
| auto maybe_node = require_package(dep_spec, frame.spec.name()); | ||
|
|
@@ -1665,42 +1667,38 @@ namespace vcpkg | |
| it->second.overlay_or_override = true; | ||
| it->second.scfl = p_overlay; | ||
| } | ||
| else if (const auto over_it = m_overrides.find(spec.name()); over_it != m_overrides.end()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GitHub's diff is freaking awful as always. This is just deleting the unused No change requested. |
||
| { | ||
| auto maybe_scfl = m_ver_provider.get_control_file({spec.name(), over_it->second}); | ||
| if (auto p_scfl = maybe_scfl.get()) | ||
| { | ||
| it = m_graph.emplace(spec, PackageNodeData{}).first; | ||
| it->second.overlay_or_override = true; | ||
| it->second.scfl = p_scfl; | ||
| } | ||
| else | ||
| { | ||
| m_errors.push_back(std::move(maybe_scfl).error()); | ||
| m_failed_nodes.insert(spec.name()); | ||
| return nullopt; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| Version ver; | ||
| if (const auto over_it = m_overrides.find(spec.name()); over_it != m_overrides.end()) | ||
| auto maybe_scfl = m_base_provider.get_baseline_version(spec.name()).then([&](const Version& ver) { | ||
| return m_ver_provider.get_control_file({spec.name(), ver}); | ||
| }); | ||
| if (auto p_scfl = maybe_scfl.get()) | ||
| { | ||
| auto maybe_scfl = m_ver_provider.get_control_file({spec.name(), over_it->second}); | ||
| if (auto p_scfl = maybe_scfl.get()) | ||
| { | ||
| it = m_graph.emplace(spec, PackageNodeData{}).first; | ||
| it->second.overlay_or_override = true; | ||
| it->second.scfl = p_scfl; | ||
| } | ||
| else | ||
| { | ||
| m_errors.push_back(std::move(maybe_scfl).error()); | ||
| m_failed_nodes.insert(spec.name()); | ||
| return nullopt; | ||
| } | ||
| it = m_graph.emplace(spec, PackageNodeData{}).first; | ||
| it->second.baseline = p_scfl->schemed_version(); | ||
| it->second.scfl = p_scfl; | ||
| } | ||
| else | ||
| { | ||
| auto maybe_scfl = m_base_provider.get_baseline_version(spec.name()).then([&](const Version& ver) { | ||
| return m_ver_provider.get_control_file({spec.name(), ver}); | ||
| }); | ||
| if (auto p_scfl = maybe_scfl.get()) | ||
| { | ||
| it = m_graph.emplace(spec, PackageNodeData{}).first; | ||
| it->second.baseline = p_scfl->schemed_version(); | ||
| it->second.scfl = p_scfl; | ||
| } | ||
| else | ||
| { | ||
| m_errors.push_back(std::move(maybe_scfl).error()); | ||
| m_failed_nodes.insert(spec.name()); | ||
| return nullopt; | ||
| } | ||
| m_errors.push_back(std::move(maybe_scfl).error()); | ||
| m_failed_nodes.insert(spec.name()); | ||
| return nullopt; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1725,22 +1723,14 @@ namespace vcpkg | |
|
|
||
| void VersionedPackageGraph::solve_with_roots(View<Dependency> deps) | ||
| { | ||
| auto dep_to_spec = [this](const Dependency& d) { | ||
| return PackageSpec{d.name, d.host ? m_host_triplet : m_toplevel.triplet()}; | ||
| }; | ||
| auto specs = Util::fmap(deps, dep_to_spec); | ||
|
|
||
| specs.push_back(m_toplevel); | ||
| Util::sort_unique_erase(specs); | ||
| for (auto&& dep : deps) | ||
| { | ||
| if (!dep.platform.is_empty() && | ||
| !dep.platform.evaluate(m_var_provider.get_or_load_dep_info_vars(m_toplevel, m_host_triplet))) | ||
| if (!dep.platform.is_empty() && !evaluate(m_toplevel, dep.platform)) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| auto spec = dep_to_spec(dep); | ||
| auto spec = PackageSpec{dep.name, dep.host ? m_host_triplet : m_toplevel.triplet()}; | ||
| m_user_requested.insert(spec); | ||
| m_roots.push_back(DepSpec{std::move(spec), dep.constraint, dep.features}); | ||
| } | ||
|
|
@@ -1824,9 +1814,7 @@ namespace vcpkg | |
| // Ignore intra-package dependencies | ||
| if (fspec == node.first) continue; | ||
|
|
||
| if (!fdep.platform.is_empty() && | ||
| !fdep.platform.evaluate( | ||
| m_var_provider.get_or_load_dep_info_vars(node.first, m_host_triplet))) | ||
| if (!fdep.platform.is_empty() && !evaluate(node.first, fdep.platform)) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate the no
{}s but that's what the other code in this function is doing so no change requested.