concretizer: add depth calculation
This commit is contained in:
parent
c410f3f392
commit
20e698c6b0
@ -1106,6 +1106,33 @@ build_priority(Package, 0) :- attr("node", Package), not optimize_for_reuse().
|
|||||||
|
|
||||||
#defined installed_hash/2.
|
#defined installed_hash/2.
|
||||||
|
|
||||||
|
%-----------------------------------------------------------------------------
|
||||||
|
% Calculate min depth of nodes in the DAG
|
||||||
|
% We use this to optimize nodes closer to roots with higher precedence.
|
||||||
|
%-----------------------------------------------------------------------------
|
||||||
|
#const max_depth = 10.
|
||||||
|
|
||||||
|
% roots have depth 0
|
||||||
|
depth(Package, 0) :- attr("root", Package).
|
||||||
|
|
||||||
|
% possible optimization
|
||||||
|
% adding this to the minimization below doesn't seem to help.
|
||||||
|
%possible_dependency(Dependent, Package) :- dependency_condition(_, Dependent, Package).
|
||||||
|
%possible_dependency(Dependent, Package) :-
|
||||||
|
% dependency_condition(_, Dependent, Virtual), possible_provider(Package, Virtual).
|
||||||
|
|
||||||
|
% other nodes' depth is the minimum depth of any dependent plus one.
|
||||||
|
depth(Package, N+1) :-
|
||||||
|
N = #min{
|
||||||
|
D: depends_on(Dependent, Package),
|
||||||
|
depth(Dependent, D),
|
||||||
|
0 <= D,
|
||||||
|
D < max_depth
|
||||||
|
},
|
||||||
|
0 <= N,
|
||||||
|
N <= max_depth,
|
||||||
|
attr("node", Package).
|
||||||
|
|
||||||
%-----------------------------------------------------------------
|
%-----------------------------------------------------------------
|
||||||
% Optimization to avoid errors
|
% Optimization to avoid errors
|
||||||
%-----------------------------------------------------------------
|
%-----------------------------------------------------------------
|
||||||
|
@ -26,3 +26,4 @@
|
|||||||
#show error/7.
|
#show error/7.
|
||||||
|
|
||||||
% debug
|
% debug
|
||||||
|
#show depth/2.
|
||||||
|
Loading…
Reference in New Issue
Block a user