MediaWiki r7267 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r7266‎ | r7267 (on ViewVC)‎ | r7268 >
Date:22:48, 26 January 2005
Author:gabrielwicke
Status:old
Tags:
Comment:
Another feature and some cleanup

-r - reply only to every nth query
Useful to dampen responses at very high request rates
set to something like 1/3 the total number of machines
Modified paths:

Diff [purge]

Index: trunk/extensions/icpagent/icpagent.c
@@ -203,17 +203,15 @@
204204 int c;
205205 icp_opcode opcode=ICP_HIT;
206206 float t=5.0;
207 - int t_int;
208 - int t_adjust;
209 - int frac;
210 - int tenloop = 0;
211 - int slow_c = 0;
212 - float step = 0;
213 - float stepsum = 0;
 207+ int t_int, t_adjust, frac;
 208+ // only answer the nth query
 209+ int replynth = 1;
 210+ // the loop counter
 211+ int maincount = 0, step = 0, stepsum = 0;
214212 struct rlimit rlim;
215213
216214 /* Work with command line options */
217 - while ((c = getopt(ac,av,"dmt:p:cn:")) != -1) {
 215+ while ((c = getopt(ac,av,"dmr:t:p:cn:")) != -1) {
218216 switch (c) {
219217 case 'p':
220218 /* Port to bind at */
@@ -236,12 +234,16 @@
237235 /* Predefined timeout value */
238236 t=atof(optarg);
239237 break;
 238+ case 'r':
 239+ /* only reply to every nth query, for high request rates */
 240+ replynth=atoi(optarg);
 241+ break;
240242 case 'n':
241243 /* Predefined nice value */
242244 nice=atoi(optarg);
243245 break;
244246 default:
245 - fprintf(stderr, "Usage: icpagent [-d] [-t delay time] [-p port] [-n nice] -m\n");
 247+ fprintf(stderr, "Usage: icpagent [-d] [-t delay time] [-p port] [-n nice] [-r reply to every rth query] -m\n");
246248 exit(-1);
247249 }
248250 }
@@ -265,9 +267,9 @@
266268
267269 /* Static delays */
268270 t_int = (int)t;
269 - frac = 10*(t - t_int + 0.0001);
 271+ frac = 100000*(t - t_int + 0.0000001);
270272 if(frac > 0)
271 - step = 10.0 / (float)frac;
 273+ step = 100000.0 / (float)frac;
272274 // printf("frac: %d, step: %f\n",frac,step);
273275 for (;;) {
274276 bzero(&them, sizeof(them));
@@ -302,23 +304,22 @@
303305 if (t<0)
304306 queuereply(them,ICP_MISS, url, header.reqnum,0);
305307 else {
306 - if(tenloop == (int)stepsum || (tenloop == 9 ) && slow_c < frac) {
 308+ if(maincount == (int)stepsum || maincount == 999999 ) {
307309 t_adjust = 1;
308 - ++slow_c;
309310 stepsum += step;
310311 } else {
311312 t_adjust = 0;
312313 }
313 - queuereply(them, opcode, url, header.reqnum, t_int+t_adjust);
 314+
 315+ if(maincount % replynth == 0)
 316+ queuereply(them, opcode, url, header.reqnum, t_int+t_adjust);
314317 }
315318
316 - // printf("t %d, slow_c %d, ss %f\n",tenloop,slow_c,stepstack);
317 - if(tenloop == 9) {
318 - tenloop = 0;
319 - slow_c = 0;
 319+ if(maincount == 999999) {
 320+ maincount = 0;
320321 stepsum=0;
321322 } else {
322 - ++tenloop;
 323+ ++maincount;
323324 }
324325 }
325326 }
Index: trunk/extensions/icpagent/README
@@ -11,6 +11,9 @@
1212 use negative number to send icp misses only
1313 supports 0.1ms adjustments by varying the response times over ten
1414 requests +/- 1ms to get the desired average.
 15+-r - reply only to every nth query
 16+ Useful to dampen responses at very high request rates
 17+ set to something like 1/3 the total number of machines
1518
1619 Example of remote management:
1720

Status & tagging log

  • 15:03, 12 September 2011 Meno25 (Talk | contribs) changed the status of r7267 [removed: ok added: old]
  • 14:06, 1 July 2009 ^demon (Talk | contribs) changed the status of r7267 [removed: new added: ok]
Personal tools
Namespaces

Variants
Views
Actions
Navigation
Support
Download
Development
Communication
Toolbox