Felix Fietkau <nbd@xxxxxxxx> writes: > On 2019-09-29 20:42, Toke Høiland-Jørgensen wrote: >> Felix Fietkau <nbd@xxxxxxxx> writes: >> >>> Rate success probability usually fluctuates a lot under normal conditions. >>> With a simple EWMA, noise and fluctuation can be reduced by increasing the >>> window length, but that comes at the cost of introducing lag on sudden >>> changes. >>> >>> This change replaces the EWMA implementation with a moving average that's >>> designed to significantly reduce lag while keeping a bigger window size >>> by being better at filtering out noise. >>> >>> It is only slightly more expensive than the simple EWMA and still avoids >>> divisions in its calculation. >>> >>> The algorithm is adapted from an implementation intended for a completely >>> different field (stock market trading), where the tradeoff of lag vs >>> noise filtering is equally important. It is based on the "smoothing filter" >>> from http://www.stockspotter.com/files/PredictiveIndicators.pdf. >>> >>> I have adapted it to fixed-point math with some constants so that it uses >>> only addition, bit shifts and multiplication >>> >>> To better make use of the filtering and bigger window size, the update >>> interval time is cut in half. >>> >>> For testing, the algorithm can be reverted to the older one via >>> debugfs >> >> This looks interesting! Do you have any performance numbers from your >> own testing to share? :) > To show the difference, I also generated some random data, ran it > through minstrel's EWMA and the new code and made a plot: > http://nbd.name/ewma-filter-plot.png Oh, wow, yeah, that looks way more responsive... > The real world test that I did was using mt76x2: > I ran 3 iperf TCP streams from an AP to a station in a cable setup with > an attenuator. > I switched from 70 dB attenuation to 40 dB and measured the time it > takes for TCP throughput to stabilize at a higher rate. > Without my changes it takes about 5-6 seconds, with my changes it's only > 2-3 seconds. Very cool. Thanks! -Toke