[openstack-dev] Weight normalization in scheduler

Álvaro López García alvaro.lopez.garcia at cern.ch
Tue Aug 13 07:53:17 UTC 2013

Hi again.

Thank you for your reply, Sandy. Some more comments inline.

On Thu 01 Aug 2013 (10:04), Sandy Walsh wrote:
> On 08/01/2013 09:51 AM, Álvaro López García wrote:
> > On Thu 01 Aug 2013 (09:07), Sandy Walsh wrote:
> >> On 08/01/2013 04:24 AM, Álvaro López García wrote:
> >>> Hi all.
> >>>
> >>> TL;DR: I've created a blueprint [1] regarding weight normalization.
> >>> I would be very glad if somebody could examine and comment it.
> >>
> >> Something must have changed. It's been a while since I've done anything
> >> with the scheduler, but normalized weights is the way it was designed
> >> and implemented.
> > 
> > It seems reasonable, but it is not there anymore:
> > 
> >     class RAMWeigher(weights.BaseHostWeigher):
> >         (...)
> >         def _weigh_object(self, host_state, weight_properties):
> >             """Higher weights win.  We want spreading to be the default."""
> >             return host_state.free_ram_mb
> Hmm, that's unfortunate. We use our own weighing functions internally,
> so perhaps we were unaffected by this change.

And that is why we spoted this. We wanted to implement our very own
functions apart from the RAMWeigher and we found that RAW values were

> >> The separate Weighing plug-ins are responsible for taking the specific
> >> units (cpu load, disk, ram, etc) and converting them into normalized
> >> 0.0-1.0 weights. Internally the plug-ins can work however they like, but
> >> their output should be 0-1.
> > 
> > With the current code, this is not true. Anyway, I think this responsability
> > should be implemented in the BaseWeightHandler rather than each weigher.
> > This way each weigher can return whatever they want, but we will be
> > always using a correct value.
> I think the problem with moving it to the base handler is that the base
> doesn't know the max range of the value ... of course, this could be
> passed down. But yeah, we wouldn't want to duplicate the normalization
> code itself in every function.

With the code in [1] the weigher can specify the maximum and minimum
values where a weight can range if it is needed (it most cases just
taking these values from the list of returned values should be enough)
and the BaseWeightHandler will normalize the list before adding them
up to the objects.

I do not see any real advantage in doing it into each weigher. Apart
from code duplication it is difficult to maintain in the long term,
since any change to the normalization should be propagated to all the
weighers (ok, now there's only one ;-) ).

[1] https://review.openstack.org/#/c/27160

Álvaro López García                              aloga at ifca.unican.es
Instituto de Física de Cantabria         http://alvarolopez.github.io
Ed. Juan Jordá, Campus UC                      tel: (+34) 942 200 969
Avda. de los Castros s/n
39005 Santander (SPAIN)

More information about the OpenStack-dev mailing list