Commit 848b65c9 authored by Iustin Pop's avatar Iustin Pop
Browse files

Use the mingain options in the balancing algorithm

Also adds them in hbal.
parent 4f807a57
......@@ -497,8 +497,10 @@ doNextBalance ini_tbl max_rounds min_score =
tryBalance :: Table -- ^ The starting table
-> Bool -- ^ Allow disk moves
-> Bool -- ^ Only evacuate moves
-> Score -- ^ Min gain threshold
-> Score -- ^ Min gain
-> Maybe Table -- ^ The resulting table and commands
tryBalance ini_tbl disk_moves evac_mode =
tryBalance ini_tbl disk_moves evac_mode mg_limit min_gain =
let Table ini_nl ini_il ini_cv _ = ini_tbl
all_inst = Container.elems ini_il
all_inst' = if evac_mode
......@@ -514,7 +516,7 @@ tryBalance ini_tbl disk_moves evac_mode =
fin_tbl = checkMove node_idx disk_moves ini_tbl reloc_inst
(Table _ _ fin_cv _) = fin_tbl
in
if fin_cv < ini_cv
if fin_cv < ini_cv && (ini_cv > mg_limit || ini_cv - fin_cv >= min_gain)
then Just fin_tbl -- this round made success, return the new table
else Nothing
......
......@@ -119,7 +119,7 @@ isNodeBig node size = Node.availDisk node > size * Types.unitDsk
&& Node.availCpu node > size * Types.unitCpu
canBalance :: Cluster.Table -> Bool -> Bool -> Bool
canBalance tbl dm evac = isJust $ Cluster.tryBalance tbl dm evac
canBalance tbl dm evac = isJust $ Cluster.tryBalance tbl dm evac 0 0
-- * Arbitrary instances
......
......@@ -70,6 +70,8 @@ options =
, oMinScore
, oMaxCpu
, oMinDisk
, oMinGain
, oMinGainLim
, oDiskMoves
, oDynuFile
, oExTags
......@@ -91,15 +93,18 @@ iterateDepth :: Cluster.Table -- ^ The starting table
-> [MoveJob] -- ^ Current command list
-> Bool -- ^ Whether to be silent
-> Score -- ^ Score at which to stop
-> Score -- ^ Min gain limit
-> Score -- ^ Min score gain
-> Bool -- ^ Enable evacuation mode
-> IO (Cluster.Table, [MoveJob]) -- ^ The resulting table
-- and commands
iterateDepth ini_tbl max_rounds disk_moves nmlen imlen
cmd_strs oneline min_score evac_mode =
cmd_strs oneline min_score mg_limit min_gain evac_mode =
let Cluster.Table ini_nl ini_il _ _ = ini_tbl
allowed_next = Cluster.doNextBalance ini_tbl max_rounds min_score
m_fin_tbl = if allowed_next
then Cluster.tryBalance ini_tbl disk_moves evac_mode
mg_limit min_gain
else Nothing
in
case m_fin_tbl of
......@@ -118,7 +123,7 @@ iterateDepth ini_tbl max_rounds disk_moves nmlen imlen
hFlush stdout
iterateDepth fin_tbl max_rounds disk_moves
nmlen imlen upd_cmd_strs oneline min_score
evac_mode
mg_limit min_gain evac_mode
Nothing -> return (ini_tbl, cmd_strs)
-- | Formats the solution for the oneline display
......@@ -273,7 +278,9 @@ main = do
(fin_tbl, cmd_strs) <- iterateDepth ini_tbl (optMaxLength opts)
(optDiskMoves opts)
nmlen imlen [] oneline min_cv (optEvacMode opts)
nmlen imlen [] oneline min_cv
(optMinGainLim opts) (optMinGain opts)
(optEvacMode opts)
let (Cluster.Table fin_nl fin_il fin_cv fin_plc) = fin_tbl
ord_plc = reverse fin_plc
sol_msg = if null fin_plc
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment