r102737 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102736‎ | r102737 | r102738 >
Date:01:52, 11 November 2011
Author:asher
Status:deferred
Tags:
Comment:
store a circular buffer of 300 time samples per profile stat, enabling 99th percentile calcs
Modified paths:
  • /trunk/udpprofile/collector.c (modified) (history)
  • /trunk/udpprofile/collector.h (modified) (history)
  • /trunk/udpprofile/export.c (modified) (history)

Diff [purge]

Index: trunk/udpprofile/export.c
@@ -23,6 +23,7 @@
2424
2525 char *p, oldhost[128]="",olddb[128]="",*pp;
2626 int indb=0,inhost=0;
 27+ int i, points;
2728
2829 struct pfstats *entry;
2930
@@ -65,11 +66,20 @@
6667 "<stats count=\"%lu\">\n" \
6768 "<cputime total=\"%lf\" totalsq=\"%lf\" />\n" \
6869 "<realtime total=\"%lf\" totalsq=\"%lf\" />\n" \
69 - "</stats></event>\n",
 70+ "<samples real=\"",
7071 (int)(key.size - ((void *)p-(void *)key.data)),p,
7172 entry->pf_count, entry->pf_cpu, entry->pf_cpu_sq,
7273 entry->pf_real, entry->pf_real_sq);
73 -
 74+ if (entry->pf_count >= POINTS) {
 75+ points = POINTS;
 76+ } else {
 77+ points = entry->pf_count;
 78+ }
 79+ for (i=0; i<points; i++) {
 80+ fprintf(fd,"%lf ", entry->pf_reals[i]);
 81+ }
 82+ fprintf(fd,"\" />\n" \
 83+ "</stats></event>\n");
7484 }
7585 fprintf(fd,"</host>\n</db>\n</pfdump>\n");
7686 c->c_close(c);
Index: trunk/udpprofile/collector.c
@@ -151,9 +151,17 @@
152152 old->pf_cpu_sq += incoming.pf_cpu_sq;
153153 old->pf_real += incoming.pf_real;
154154 old->pf_real_sq += incoming.pf_real_sq;
 155+ old->pf_reals[old->pf_real_pointer] = incoming.pf_real;
 156+ if (old->pf_real_pointer == POINTS-1) {
 157+ old->pf_real_pointer = 0;
 158+ } else {
 159+ old->pf_real_pointer++;
 160+ }
155161 db->put(db,NULL,&key,&data,0);
156162 } else {
157163 /* Put in fresh data */
 164+ incoming.pf_real_pointer = 1;
 165+ incoming.pf_reals[0] = incoming.pf_real;
158166 data.data=&incoming;
159167 data.size=sizeof(incoming);
160168 db->put(db,NULL,&key,&data,0);
Index: trunk/udpprofile/collector.h
@@ -3,7 +3,7 @@
44
55 #include <stdio.h>
66 #include <db.h>
7 -
 7+#define POINTS 300
88 DB *db;
99
1010 /* Stats variables, not that generic, are they? */
@@ -14,6 +14,8 @@
1515 double pf_cpu_sq;
1616 double pf_real;
1717 double pf_real_sq;
 18+ int pf_real_pointer;
 19+ double pf_reals[POINTS];
1820 };
1921
2022 void dumpData(FILE *);

Status & tagging log