Search Linux Wireless

Re: [RFC v2] average: rewrite for clearity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 24.04.2023 um 17:55 schrieb Johannes Berg:
________________________________
  Achtung! Externe E-Mail: Klicken Sie erst dann auf Links und Anhänge, nachdem Sie die Vertrauenswürdigkeit der Absenderadresse geprüft haben.
________________________________

On Fri, 2023-04-21 at 17:16 +0200, Benjamin Beichler wrote:
IMHO the net improvement is, that if you do not use the convenience
add_or_init function, it simply resembles the ewma filter of a math or
CS-textbook.
Not sure I see that as a good argument. The practical engineering side
tends to always be more complex than the theory, and that's not really
unexpected. We can comment why it's different :-)
In my opinion, the behavior was without good reason unexpected, but I think I found a solution, that we are all happy with. See v3.

The original problem was, that the ewma had a surprising
output in a special situation.
Right, but that's an implementation issue, because we thought 0 ==
uninit was clever, without realizing the corner case.

But while writing the commit, I recognized, that the current ewma
implementation is only for unsigned values, which means the problem
really only happens for many consecutive 0 values. I try to think over,
what this means for the proposal of Felix, but I'm not able to think
about unsigned C-arithmetics today :-D
Not much really, I think? It eases thinking about it though :)

If we use that fix, then we should have an additional compile time
check, that the precision has at least 2 or 4 bits, to really avoid the
problem, shouldn't we?
Yes. I think 1 bit is enough, but yes, it can't be 0 bits.

I have wrapped my head around it again, and just send a new version (which I may split in two patches for the final round). I played around with the fixed point arithmetic and came to the conclusion, that ULONG_MAX is a better candidate for initial state, since for valid EWMA configurations, i.e. a weight_rcp bigger than 1, ULONG_MAX is never reached. Actually, a precision (or fraction) bigger than 0 seems to be not needed. However, this means maybe some unexpected oscillation at the lower bits, so we may enforce it by another compile time check, but actually I' not really concerned about that :-D

In contrast, I recognized, that if val is too big for the weight_rcp/precision combination, it can overflow the internal state and result into much lower values and unexpected jumps of the state. Currently, I just added a WARN_ONCE for this. For all current users, this problem should never happen, but a separate clamping of the input val is maybe too much, and could also be easily implemented by the user of the function.

Benjamin




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux