Skip to content
Snippets Groups Projects
Commit 8a3b30ca authored by Iustin Pop's avatar Iustin Pop
Browse files

Introduce per-metric weights

Currently all metrics have the same weight (we just sum them together).
However, for the hard constraints (N+1 failures, offline nodes, etc.)
we should handle the metrics differently based on their meaning. For
example, an instance living on a primary offline node is worse than an
instance having its secondary node offline, which in turn is worse than
an instance having its secondary node failing N+1.

To express this case in our code, we introduce a table of weights for
the metrics, with which we can influence their relative importance.
parent 2cae47e9
No related branches found
No related tags found
No related merge requests found
...@@ -202,21 +202,24 @@ computeAllocationDelta cini cfin = ...@@ -202,21 +202,24 @@ computeAllocationDelta cini cfin =
runa = RSpec un_cpu (truncate t_mem - f_imem) (truncate t_dsk - f_idsk) runa = RSpec un_cpu (truncate t_mem - f_imem) (truncate t_dsk - f_idsk)
in (rini, rfin, runa) in (rini, rfin, runa)
-- | The names of the individual elements in the CV list -- | The names and weights of the individual elements in the CV list
detailedCVNames :: [String] detailedCVInfo :: [(Double, String)]
detailedCVNames = [ "free_mem_cv" detailedCVInfo = [ (1, "free_mem_cv")
, "free_disk_cv" , (1, "free_disk_cv")
, "n1_cnt" , (1, "n1_cnt")
, "reserved_mem_cv" , (1, "reserved_mem_cv")
, "offline_all_cnt" , (4, "offline_all_cnt")
, "offline_pri_cnt" , (16, "offline_pri_cnt")
, "vcpu_ratio_cv" , (1, "vcpu_ratio_cv")
, "cpu_load_cv" , (1, "cpu_load_cv")
, "mem_load_cv" , (1, "mem_load_cv")
, "disk_load_cv" , (1, "disk_load_cv")
, "net_load_cv" , (1, "net_load_cv")
, "pri_tags_score" , (1, "pri_tags_score")
] ]
detailedCVWeights :: [Double]
detailedCVWeights = map fst detailedCVInfo
-- | Compute the mem and disk covariance. -- | Compute the mem and disk covariance.
compDetailedCV :: Node.List -> [Double] compDetailedCV :: Node.List -> [Double]
...@@ -265,7 +268,7 @@ compDetailedCV nl = ...@@ -265,7 +268,7 @@ compDetailedCV nl =
-- | Compute the /total/ variance. -- | Compute the /total/ variance.
compCV :: Node.List -> Double compCV :: Node.List -> Double
compCV = sum . compDetailedCV compCV = sum . zipWith (*) detailedCVWeights . compDetailedCV
-- | Compute online nodes from a Node.List -- | Compute online nodes from a Node.List
getOnline :: Node.List -> [Node.Node] getOnline :: Node.List -> [Node.Node]
...@@ -797,9 +800,10 @@ printInsts nl il = ...@@ -797,9 +800,10 @@ printInsts nl il =
printStats :: Node.List -> String printStats :: Node.List -> String
printStats nl = printStats nl =
let dcvs = compDetailedCV nl let dcvs = compDetailedCV nl
hd = zip (detailedCVNames ++ repeat "unknown") dcvs (weights, names) = unzip detailedCVInfo
formatted = map (\(header, val) -> hd = zip3 (weights ++ repeat 1) (names ++ repeat "unknown") dcvs
printf "%s=%.8f" header val::String) hd formatted = map (\(w, header, val) ->
printf "%s=%.8f(x%.2f)" header val w::String) hd
in intercalate ", " formatted in intercalate ", " formatted
-- | Convert a placement into a list of OpCodes (basically a job). -- | Convert a placement into a list of OpCodes (basically a job).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment