From: anshul makkar <anshul.makkar@citrix.com>
To: George Dunlap <george.dunlap@citrix.com>, xen-devel@lists.xenproject.org
Cc: Ian Jackson <ian.jackson@citrix.com>,
Dario Faggioli <dario.faggioli@citrix.com>,
Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH 4/4] tools/xenalyze: Allow automatic resizing of sample buffers
Date: Mon, 8 Aug 2016 18:11:02 +0100 [thread overview]
Message-ID: <57A8BD26.1060507@citrix.com> (raw)
In-Reply-To: <1470650071-1157-4-git-send-email-george.dunlap@citrix.com>
On 08/08/16 10:54, George Dunlap wrote:
> Rather than have large fixed-size buffers, start with smaller buffers
> and allow them to grow as needed (doubling each time), with a fairly
> large maximum. Allow this maximum to be set by a command-line
> parameter.
>
> Signed-off-by: George Dunlap <george.dunlap@citrix.com>
> ---
> CC: Ian Jackson <ian.jackson@citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Dario Faggioli <dario.faggioli@citrix.com>
> CC: Anshul Makkar <anshul.makkar@citrix.com>
> ---
> tools/xentrace/xenalyze.c | 95 +++++++++++++++++++++++++++++++++--------------
> 1 file changed, 68 insertions(+), 27 deletions(-)
>
> diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c
> index 455cbdf..a4d8823 100644
> --- a/tools/xentrace/xenalyze.c
> +++ b/tools/xentrace/xenalyze.c
> @@ -44,7 +44,8 @@ struct mread_ctrl;
> #define QHZ_FROM_HZ(_hz) (((_hz) << 10)/ 1000000000)
>
> #define ADDR_SPACE_BITS 48
> -#define DEFAULT_SAMPLE_SIZE 10240
> +#define DEFAULT_SAMPLE_SIZE 1024
> +#define DEFAULT_SAMPLE_MAX 1024*1024*32
> #define DEFAULT_INTERVAL_LENGTH 1000
>
> s->event_count++;
>
> if (!c)
> return;
>
> if(opt.sample_size) {
> - int lap = (s->count/opt.sample_size)+1,
> - index =s->count % opt.sample_size;
> - if((index - (lap/3))%lap == 0) {
> - if(!s->sample) {
> - s->sample = malloc(sizeof(*s->sample) * opt.sample_size);
> - if(!s->sample) {
> - fprintf(stderr, "%s: malloc failed!\n", __func__);
> - error(ERR_SYSTEM, NULL);
> - }
> + if (s->count >= s->sample_size
> + && (s->count == 0
> + || opt.sample_max == 0
> + || s->sample_size < opt.sample_max)) {
> + int new_size;
> + void * new_sample = NULL;
> +
> + new_size = s->sample_size << 1;
Sorry for my ignorance here, but why we have chosen to double the size.
Can't we increase by fixed size X where X < double size. Are we sure
that we will be able to fully utilize the double sized buffer.
> +
> + if (new_size == 0)
> + new_size = opt.sample_size;
> +
> + if (opt.sample_max != 0 && new_size > opt.sample_max)
> + new_size = opt.sample_max;
> +
> + //printf("New size: %d\n", new_size);
> +
> + new_sample = realloc(s->sample, sizeof(*s->sample) * new_size);
> +
> + if (new_sample) {
> + s->sample = new_sample;
> + s->sample_size = new_size;
> }
> - s->sample[index]=c;
> }
> +
> + if (s->count < s->sample_size) {
> + s->sample[s->count]=c;
> + } else {
> + /*
> + * If we run out of space for samples, start taking only a
> + * subset of samples.
> + */
> + int lap, index;
> + lap = (s->count/s->sample_size)+1;
> + index =s->count % s->sample_size;
> + if((index - (lap/3))%lap == 0) {
> + s->sample[index]=c;
> + }
> + }
> }
> s->count++;
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-08-08 17:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-08 9:54 [PATCH 1/4] tools/xenalyze: Remove bogus library dependencies George Dunlap
2016-08-08 9:54 ` [PATCH 2/4] tools/xenalyze: Remove weighted cpi summaries George Dunlap
2016-08-08 11:06 ` Wei Liu
2016-08-08 9:54 ` [PATCH 3/4] tools/xenalyze: Get rid of extraneous data structure George Dunlap
2016-08-08 11:06 ` Wei Liu
2016-08-08 9:54 ` [PATCH 4/4] tools/xenalyze: Allow automatic resizing of sample buffers George Dunlap
2016-08-08 11:05 ` Wei Liu
2016-08-08 11:09 ` Wei Liu
2016-08-09 14:48 ` George Dunlap
2016-08-08 17:11 ` anshul makkar [this message]
2016-08-09 10:01 ` George Dunlap
2016-08-08 11:06 ` [PATCH 1/4] tools/xenalyze: Remove bogus library dependencies Wei Liu
2016-08-08 12:25 ` Dario Faggioli
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=57A8BD26.1060507@citrix.com \
--to=anshul.makkar@citrix.com \
--cc=dario.faggioli@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=ian.jackson@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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).