Hi Ratz,
On Fri, 25 Jul 2003, Roberto Nibali wrote:
>
> I see that the rate estimator currently is not used anywhere. From what
> I understand it tries to give you a means to provide 1/s information on
> packets, bytes and connections.
>
> I wonder why it is done in such a complicated way? I know most of it is
It isn't complicated. :)
> from the net/sched/estimator.c but why not using the direct way of
> computing the average?
>
> Something like following should work:
>
> avg = ((time - timeframe) * avg + new) / time
>
Your formula is the same as avgrate = avgrate*(1-W) + rate*W, where W is
timeframe/time. Oh, you miss something in your formula, it should be
avg = ((time - timeframe) * avg + timeframe * new) / time
> I've written a 2 minutes POC shell script that shows what I mean:
>
> ------------------------------------------------------------------
> #!/bin/bash
> # extremely stupid programme to show calculation of constant average
>
> declare -i num=0
> declare -i cnt=0
> declare -i timeframe=2
> declare avg=0
>
> while read -p "Enter number: " num rest; do
> if [ "${rest}" == "q" ]; then
> exit
> fi
>
> cnt=$((${cnt}+${timeframe}))
> avg=$(echo "((${cnt}-${timeframe})*${avg}+${num})/${cnt}" | bc -l)
> printf "Average [cnt=%d]: %0.4f\n" "${cnt}" "${avg}"
> done
> ------------------------------------------------------------------
>
> Why are the numbers scaled by 2^5?
>
For more precise numbers, we keep the 1/32 fraction numbers in the
counter.
> Would it make sense to use the ip_vs_estimator to write a scheduler
> which chooses the RS with either the least amount of bps or the least
> amount of pps?
>
Yes, it's possible, but it will make ipvsadm a little bit more complicated
to set those bps/pps thresholds.
Cheers,
Wensong
|