qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Benoît Canet" <benoit.canet@nodalink.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 3/3] util: Infrastructure for computing recent averages
Date: Mon, 13 Oct 2014 14:05:34 +0200	[thread overview]
Message-ID: <543BC00E.2060907@redhat.com> (raw)
In-Reply-To: <1411572065-18072-4-git-send-email-benoit.canet@nodalink.com>

Il 24/09/2014 17:21, Benoît Canet ha scritto:
> The module takes care of computing minimal and maximal
> values over the time slice duration.

The code looks good, just two comments:

> +/* Get the average value
> + *
> + * @ta:  the timed average structure used
> + * @ret: the average value
> + */
> +uint64_t timed_average_avg(TimedAverage *ta)
> +{
> +    Window *w;
> +    check_expirations(ta);
> +
> +    w = current_window(ta);
> +
> +    if (w->count) {
> +        return w->sum / w->count;

First, do we want this to return double?

Second, this will return the min/max/avg in an unknown amount of time
between period/2 and period---on average period*3/4, e.g. 0.75 seconds
for a period equal to one second.

Would it make sense to tweak the TimedAverage period to be higher, e.g.
1.33 seconds/80 seconds/80 minutes, so that the _average_ period is 1
second/1 minute/1 hour?

This only applies to how the code is used, not to TimedAverage itself;
hence, feel free to post the patch with Reviewed-by once
timed_average_avg's return type is changed to a double.

Paolo

> +    }
> +
> +    return 0;
> +}
> +
> +/* Get the maximum value
> + *
> + * @ta:  the timed average structure used
> + * @ret: the maximal value
> + */
> +uint64_t timed_average_max(TimedAverage *ta)
> +{
> +    check_expirations(ta);
> +    return current_window(ta)->max;
> +}
> 

  reply	other threads:[~2014-10-13 12:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-24 15:21 [Qemu-devel] [PATCH v3 0/3] timed average infrastructure for use in block statistics Benoît Canet
2014-09-24 15:21 ` [Qemu-devel] [PATCH v3 1/3] throttle: Make NANOSECONDS_PER_SECOND an integer Benoît Canet
2014-09-24 16:33   ` Eric Blake
2014-09-24 15:21 ` [Qemu-devel] [PATCH v3 2/3] timers: Move NANOSECONDS_PER_SECONDS to timer.h for future reuse Benoît Canet
2014-09-24 15:33   ` Paolo Bonzini
2014-09-24 15:33   ` Paolo Bonzini
2014-09-29 16:04     ` Benoît Canet
2014-09-29 21:54       ` Paolo Bonzini
2014-09-29 23:08         ` Benoît Canet
2014-09-24 15:21 ` [Qemu-devel] [PATCH v3 3/3] util: Infrastructure for computing recent averages Benoît Canet
2014-10-13 12:05   ` Paolo Bonzini [this message]
2014-10-13 15:06     ` Benoît Canet

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=543BC00E.2060907@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=benoit.canet@nodalink.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).