247 | | #define MIN_SAMPLES 20 |
248 | | // after this many samples, use exponentially averaged version |
249 | | #define SAMPLE_WEIGHT 0.001 |
250 | | // new samples get this weight in exp avg |
251 | | #define SAMPLE_LIMIT 10 |
252 | | // cap samples at recent_mean*10 |
| 247 | #define MIN_SAMPLES 20 |
| 248 | // after this many samples, use exponentially averaged version |
| 249 | #define SAMPLE_WEIGHT 0.001 |
| 250 | // new samples get this weight in exp avg |
| 251 | #define SAMPLE_LIMIT 10 |
| 252 | // cap samples at recent_mean*10 |
262 | | if (sample < 0) return; |
263 | | if (nsamples > MIN_SAMPLES) { |
264 | | if (sample > recent_mean*SAMPLE_LIMIT) { |
265 | | sample = recent_main*SAMPLE_LIMIT; |
266 | | } |
267 | | } |
268 | | // see http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance |
269 | | nsamples++; |
270 | | double delta = sample - mean; |
271 | | mean += delta/nsamples; |
272 | | sum_var += delta*(sample-mean); |
273 | | |
274 | | if (nsamples < MIN_SAMPLES) { |
275 | | recent_mean = mean; |
276 | | recent_var = sum_var/nsamples; |
277 | | } else { |
278 | | // update recent averages |
279 | | delta = sample - recent_mean; |
280 | | recent_mean += SAMPLE_WEIGHT*delta; |
281 | | double d2 = delta*delta - recent_var; |
282 | | recent_var += SAMPLE_WEIGHT*d2; |
283 | | } |
| 262 | if (sample < 0) return; |
| 263 | if (nsamples > MIN_SAMPLES) { |
| 264 | if (sample > recent_mean*SAMPLE_LIMIT) { |
| 265 | sample = recent_main*SAMPLE_LIMIT; |
| 266 | } |
| 267 | } |
| 268 | // see http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance |
| 269 | nsamples++; |
| 270 | double delta = sample - mean; |
| 271 | mean += delta/nsamples; |
| 272 | sum_var += delta*(sample-mean); |
| 273 | |
| 274 | if (nsamples < MIN_SAMPLES) { |
| 275 | recent_mean = mean; |
| 276 | recent_var = sum_var/nsamples; |
| 277 | } else { |
| 278 | // update recent averages |
| 279 | delta = sample - recent_mean; |
| 280 | recent_mean += SAMPLE_WEIGHT*delta; |
| 281 | double d2 = delta*delta - recent_var; |
| 282 | recent_var += SAMPLE_WEIGHT*d2; |
| 283 | } |
340 | | Database changes: |
341 | | |
342 | | New table "host_app_version" |
343 | | {{{ |
344 | | int host_id; |
345 | | int app_version_id; |
346 | | double avg_vnpfc; // recent average |
347 | | int njobs; |
348 | | double total_vnpfc; |
349 | | }}} |
350 | | |
351 | | New fields in "app_version": |
352 | | {{{ |
353 | | double avg_vnpfc; |
354 | | int njobs; |
355 | | double total_vnpfc; |
356 | | }}} |
357 | | |
358 | | New fields in "app": |
359 | | {{{ |
360 | | double min_avg_vnpfc; // min value of app_version.avg_vnpfc |
361 | | }}} |
362 | | |
| 348 | === Database changes === |
| 349 | |
| 350 | New table '''host_app''': |
| 351 | {{{ |
| 352 | int host_id; |
| 353 | int app_id; |
| 354 | int vnpfc_n; |
| 355 | double vnpfc_mean; |
| 356 | double vnpfc_sum_var; |
| 357 | double vnpfc_recent_mean; |
| 358 | double vnpfc_recent_var; |
| 359 | }}} |
| 360 | |
| 361 | New table '''host_app_version''': |
| 362 | {{{ |
| 363 | int host_id; |
| 364 | int app_version_id; |
| 365 | int et_n; |
| 366 | double et_mean; |
| 367 | double et_sum_var; |
| 368 | double et_recent_mean; |
| 369 | double et_recent_var; |
| 370 | }}} |
| 371 | |
| 372 | New fields in '''app_version''': |
| 373 | {{{ |
| 374 | int pfc_n; |
| 375 | double pfc_mean; |
| 376 | double pfc_sum_var; |
| 377 | double pfc_recent_mean; |
| 378 | double pfc_recent_var; |
| 379 | double pfc_scaling_factor; |
| 380 | }}} |
| 381 | |
| 382 | New fields in '''app''': |
| 383 | {{{ |
| 384 | int vnpfc_n; |
| 385 | double vnpfc_mean; |
| 386 | double vnpfc_sum_var; |
| 387 | double vnpfc_recent_mean; |
| 388 | double vnpfc_recent_var; |
| 389 | }}} |
| 390 | |
| 391 | === New request message fields === |
| 392 | |
| 393 | === New reply message fields === |
| 394 | |
| 395 | === Scheduler changes === |
| 396 | |
| 397 | === Client changes === |
| 398 | |
| 399 | === Validator changes === |
| 400 | |
| 401 | === Server APIs for computing and granting credit === |
| 402 | |
| 403 | == Compatibility == |