On Mon, Oct 05, 2015 at 09:54:09AM +0200, 'Oleg Ponomarev' via ganeti-devel wrote: > Introduce new formula of pMem calculating that works good with memory > over-commitment. fMem / tMem is replaced withi fMem / (tMem - nMem)
s/$/. > tMem replaced with tMem - nMem because we care of memory which can be > used for instance placement. Negative values of pMem mean active > memory ovet-commitment. > > Signed-off-by: Oleg Ponomarev <[email protected]> > --- > src/Ganeti/HTools/Node.hs | 24 ++++++++++++++++-------- > 1 file changed, 16 insertions(+), 8 deletions(-) > @@ -394,6 +394,10 @@ mCpuTohiCpu mval = floor . (mval *) > computeHiSpindles :: Double -> Int -> Double > computeHiSpindles spindle_ratio = (spindle_ratio *) . fromIntegral > > +-- | Conversion formula from fMem, tMem and nMem to pMem. > +computePmem :: Int -> Double -> Int -> Double > +computePmem fmem tmem nmem = fromIntegral fmem / (tmem - fromIntegral nmem) > + Please move up so that functions are introduced before use (as per our style guide). > -- | Computes the maximum reserved memory for peers from a peer map. > @@ -460,15 +466,17 @@ computeMaxRes = P.maxElem > > -- | Calculates the lower acceptable amount of free memory. It's a negative > -- value, thanks to memory over-commitment > - > fMemTresholdHelper :: Double -> Double -> Int -> Int > fMemTresholdHelper ratio tmem nmem = > truncate $ -(ratio - 1) * (tmem - fromIntegral nmem) > > +-- | More convenient way of calling fMemTresholdHelper in case of initialized > +-- instance > fMemTreshold :: Node -> Int > fMemTreshold t = > fMemTresholdHelper (T.iPolicyMemoryRatio $ iPolicy t) (tMem t) (nMem t) > > + Changes unrelated to this patch; see also comments on the patch they belong to. Rest looks good. -- Klaus Aehlig Google Germany GmbH, Dienerstr. 12, 80331 Muenchen Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschaeftsfuehrer: Graham Law, Christine Elizabeth Flores
