From: Bruno Randolf <br1@einfach.org>
To: kevin granade <kevin.granade@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Randy Dunlap <randy.dunlap@oracle.com>,
akpm <akpm@linux-foundation.org>
Subject: Re: [PATCH] Add generic exponentially weighted moving average function
Date: Mon, 18 Oct 2010 12:27:06 +0900 [thread overview]
Message-ID: <201010181227.06877.br1@einfach.org> (raw)
In-Reply-To: <AANLkTim+wuzaak=VP3uq=SefGMq_fzr3MR0yF+PKQTdw@mail.gmail.com>
On Fri October 15 2010 22:55:23 kevin granade wrote:
> >> This has a scaled up copy of the moving average, which reduces the
> >> available range for the average to MAX_INT/(AVG_FACTOR*num_samples)
> >> instead of +/- MAX_INT, is that acceptable? Even if it is, shouldn't
> >> it be documented? For example, with num_samples = 10, it will roll
> >> over to a negative value if the average exceeds 214,748. This seems
> >> like a potentially surprising outcome.
> >
> > Yes. I'll document this in the next version of the patch. Or should I use
> > 64bit for the internal representation?
>
> If you don't expect the size or speed impact to be significant, it
> seems like just throwing a bigger number at the problem might be the
> better option. That will move the rollover to MAX_INT/AVG_FACTOR,
> unless you also make AVG_FACTOR 64bit, which will promote all of the
> multiplications to 64bit and provide full MAX_INT range for input and
> output.
Honestly, I don't know about the speed impact of using 64 bit vs. 32 bit.
I do know however, that the averaging function needs to be called quite often,
where I want to use it, so performance could be an issue. And in my case the
values are low enough so rollover is not a problem - but obviously I want to
make this generally useful.
> I couldn't find anything that clearly indicated what the expected
> precaution is in this case. It probably isn't an issue now that I
> understand that samples is intended to remain constant. I initially
> thought samples would scale from 1 - n as you were initially "loading"
> samples into the structure, but now I understand that samples remains
> at n throughout the process.
I will work on the description.
Thanks,
Bruno
prev parent reply other threads:[~2010-10-18 3:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-06 9:32 Bruno Randolf
2010-10-13 0:33 ` Randy Dunlap
2010-10-13 2:10 ` Bruno Randolf
2010-10-13 16:33 ` Randy Dunlap
2010-10-15 3:40 ` Ben Pfaff
2010-10-15 14:41 ` Randy Dunlap
2010-10-13 14:01 ` kevin granade
2010-10-14 1:19 ` Bruno Randolf
2010-10-15 13:55 ` kevin granade
2010-10-18 3:27 ` Bruno Randolf [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201010181227.06877.br1@einfach.org \
--to=br1@einfach.org \
--cc=akpm@linux-foundation.org \
--cc=kevin.granade@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=randy.dunlap@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome