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.dun...@citrix.com>
---
CC: Ian Jackson <ian.jack...@citrix.com>
CC: Wei Liu <wei.l...@citrix.com>
CC: Dario Faggioli <dario.faggi...@citrix.com>
CC: Anshul Makkar <anshul.mak...@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