From: Martin Wilck <mwilck@suse.com>
To: Guan Junxiong <guanjunxiong@huawei.com>,
Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: dm-devel@redhat.com, niuhaoxin <niuhaoxin@huawei.com>,
"Shenhong (C)" <shenhong09@huawei.com>
Subject: Re: [PATCH 3/4] libmultipath: path latency: simplify getprio()
Date: Mon, 20 Nov 2017 09:46:46 +0100 [thread overview]
Message-ID: <1511167606.25459.21.camel@suse.com> (raw)
In-Reply-To: <74584b90-53c7-341e-d422-dca85c267c90@huawei.com>
Hello Guan,
> On 2017/11/18 8:11, Martin Wilck wrote:
> > The log standard deviation can be calculated much more simply
> > by realizing
> >
> > sum_n (x_i - avg(x))^2 == sum_n x_i^2 - n * avg(x)^2
> >
>
> I derive the equation:
> sum_n {(x_i - avg(x))^2} = sum_n{x_i^2 -2*x_i*avg(x) + avg(x)^2}
> = sum_n{x_i^2} - 2*avg(x)*sum_n{x_i} +
> sum_n{avg(x)^2}
> = sum_n{x_i^2} - 2*avg(x)*avg(x) +
> n*avg(x)^2
> = sum_n{x_i^2} + (n-2)*avg(x)^2
No, that's wrong:
avg(x) = (1/n) * sum_n(x_i)
=> sum_n(x_i) = n * avg(x)
Thus the 2nd term in the line before the last in your derivation
is not "- 2*avg(x)*avg(x)", but "- 2*n*avg(x)*avg(x)", and the end
result becomes sum_n(x_i^2) - n*avg(x)^2.
>
> > Also, use timespecsub rather than the custom timeval_to_usec,
> > and avoid taking log(0).
> >
>
> Great.
>
>
> > + pp_pl_log(3, "%s: latency avg=%.2e uncertainty=%.1f
> > prio=%d\n",
>
> latency avg -> latency geometric avg ? Because in most cases,
> avg means arithmetic avg , but in this case, it means geometric avg.
Yes, I meant the geometric average. I don't think we should bother the
user with these subtleties. Well, maybe it would feel better if we'd
use "geometric mean" rather than "avg" in the log message, alhough that
might again irritate some people who don't know the term ... I really
don't care much.
> > + pp->dev, exp(lg_avglatency * lg_base),
> > + exp(standard_deviation * lg_base), rc);
>
> How can you get the uncertainty of Log-normal distribution
> is the exp(standard_deviation * lg_base) ?
The "width" of the normal distribution is measured in terms of the
standard deviation, sigma. In your patch, you correctly accounted for
the confidence levels of the 2*sigma environment
(https://en.wikipedia.org/wiki/68%E2%80%9395%E2%80%9399.7_rule).
Here, we're assuming a log-normal distribution for the latency (it's a
practical assumption, not a statistical assertion - in reality the
latency probably rather follows an exponential or Poisson distribution
but we don't need to go into that detail). That means we're assuming
that log(latency) can be described by a normal distribution with a
certain standard deviation sigma around the log of the geometric mean.
Again, sigma is the "width" of that normal distribution. Thus with ~68%
probability, the log of the the latency is in the 1-sigma interval
around the average. Translating that back into "real" latency, with 68%
likelyhood it will be in the interval [(1/F) * gm, F*gm], where gm is
the geometric mean and F=exp(sigma). Therefore, F (which is
exp(standard_deviation * lg_base)) can be used as an estimate of the
"uncertainty factor" for the latency.
Agreed?
Regards
Martin
--
Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
next prev parent reply other threads:[~2017-11-20 8:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-18 0:11 [PATCH 0/4] path latency prio fixes Martin Wilck
2017-11-18 0:11 ` [PATCH 1/4] libmultipath: path latency: fix default base num Martin Wilck
2017-11-19 2:19 ` Guan Junxiong
2017-11-18 0:11 ` [PATCH 2/4] libmultipath: path latency: log threshold with p2 Martin Wilck
2017-11-19 2:23 ` Guan Junxiong
2017-11-18 0:11 ` [PATCH 3/4] libmultipath: path latency: simplify getprio() Martin Wilck
2017-11-19 2:52 ` Guan Junxiong
2017-11-20 8:46 ` Martin Wilck [this message]
2017-12-07 4:26 ` Guan Junxiong
2017-12-07 15:56 ` Martin Wilck
2017-11-18 0:11 ` [PATCH 4/4] libmultipath: path latency: remove warnings Martin Wilck
2017-11-19 3:00 ` Guan Junxiong
2017-11-20 9:11 ` [PATCH 0/4] path latency prio fixes Martin Wilck
2017-12-08 20:49 ` Benjamin Marzinski
[not found] <06F84A57D601574CAA706EE1A6270A5F01039500@DGGEMM505-MBX.china.huawei.com>
2017-11-23 2:20 ` [PATCH 3/4] libmultipath: path latency: simplify getprio() Guan Junxiong
2017-11-23 12:23 ` Martin Wilck
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=1511167606.25459.21.camel@suse.com \
--to=mwilck@suse.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@redhat.com \
--cc=guanjunxiong@huawei.com \
--cc=niuhaoxin@huawei.com \
--cc=shenhong09@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.