[137974ae] | 1 | #include "printer.hfa"
|
---|
[329e26a] | 2 | #include "options.hfa"
|
---|
[137974ae] | 3 |
|
---|
[32d1383] | 4 | #include <clock.hfa>
|
---|
[137974ae] | 5 | #include <fstream.hfa>
|
---|
| 6 | #include <stats.hfa>
|
---|
| 7 |
|
---|
| 8 | void ?{}( sendfile_stats_t & this ) {
|
---|
[ae020ea] | 9 | this.maxfd = 0;
|
---|
| 10 | this.close = 0;
|
---|
[137974ae] | 11 | this.calls = 0;
|
---|
| 12 | this.tries = 0;
|
---|
| 13 | this.header = 0;
|
---|
| 14 | this.splcin = 0;
|
---|
| 15 | this.splcot = 0;
|
---|
| 16 | for(i; zipf_cnts) {
|
---|
| 17 | this.avgrd[i].calls = 0;
|
---|
| 18 | this.avgrd[i].bytes = 0;
|
---|
| 19 | };
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | void push(sendfile_stats_t & from, sendfile_stats_t & to) {
|
---|
[ae020ea] | 23 | to.maxfd = max( to.maxfd, from.maxfd);
|
---|
| 24 | to.close += from.close; from.close = 0;
|
---|
[32d1383] | 25 | to.error += from.error; from.error = 0;
|
---|
[ae020ea] | 26 | to.calls += from.calls; from.calls = 0;
|
---|
[32d1383] | 27 | to.eagain += from.eagain; from.eagain = 0;
|
---|
[ae020ea] | 28 | to.tries += from.tries; from.tries = 0;
|
---|
| 29 | to.header += from.header; from.header = 0;
|
---|
| 30 | to.splcin += from.splcin; from.splcin = 0;
|
---|
| 31 | to.splcot += from.splcot; from.splcot = 0;
|
---|
[137974ae] | 32 | for(i; zipf_cnts) {
|
---|
[ae020ea] | 33 | to.avgrd[i].calls += from.avgrd[i].calls; from.avgrd[i].calls = 0;
|
---|
| 34 | to.avgrd[i].bytes += from.avgrd[i].bytes; from.avgrd[i].bytes = 0;
|
---|
[137974ae] | 35 | };
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | void ?{}( acceptor_stats_t & this ) {
|
---|
| 39 | this.creates = 0;
|
---|
| 40 | this.accepts = 0;
|
---|
| 41 | this.eagains = 0;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | void push(acceptor_stats_t & from, acceptor_stats_t & to) {
|
---|
[ae020ea] | 45 | to.creates += from.creates; from.creates = 0;
|
---|
| 46 | to.accepts += from.accepts; from.accepts = 0;
|
---|
| 47 | to.eagains += from.eagains; from.eagains = 0;
|
---|
[137974ae] | 48 | }
|
---|
| 49 |
|
---|
[329e26a] | 50 | void ?{}( StatsPrinter & this, ServerCluster * cl ) {
|
---|
[bf7c7ea] | 51 | ((thread&)this){ "Stats Printer Thread" };
|
---|
[329e26a] | 52 | this.cl = cl;
|
---|
[137974ae] | 53 | memset(&this.stats, 0, sizeof(this.stats));;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | void ^?{}( StatsPrinter & mutex this ) {}
|
---|
| 57 |
|
---|
| 58 | #define eng3(X) (ws(3, 3, unit(eng( X ))))
|
---|
| 59 |
|
---|
| 60 | void main(StatsPrinter & this) {
|
---|
| 61 | LOOP: for() {
|
---|
| 62 | wait(this.var, 10`s);
|
---|
| 63 |
|
---|
[329e26a] | 64 | for(i; options.clopts.nclusters) print_stats_now( this.cl[i].self, CFA_STATS_READY_Q | CFA_STATS_IO );
|
---|
[137974ae] | 65 | {
|
---|
| 66 | struct {
|
---|
| 67 | volatile uint64_t calls;
|
---|
| 68 | volatile uint64_t bytes;
|
---|
| 69 | } avgrd[zipf_cnts];
|
---|
| 70 | memset(avgrd, 0, sizeof(avgrd));
|
---|
| 71 |
|
---|
| 72 | uint64_t tries = this.stats.send.tries;
|
---|
| 73 | uint64_t calls = this.stats.send.calls;
|
---|
| 74 | uint64_t header = this.stats.send.header;
|
---|
| 75 | uint64_t splcin = this.stats.send.splcin;
|
---|
| 76 | uint64_t splcot = this.stats.send.splcot;
|
---|
| 77 | for(j; zipf_cnts) {
|
---|
| 78 | avgrd[j].calls += this.stats.send.avgrd[j].calls;
|
---|
| 79 | avgrd[j].bytes += this.stats.send.avgrd[j].bytes;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | double ratio = ((double)tries) / calls;
|
---|
[ae020ea] | 83 | uint64_t accp_open = this.stats.accpt.accepts;
|
---|
| 84 | uint64_t accp_clse = this.stats.send.close;
|
---|
[32d1383] | 85 | uint64_t accp_errs = this.stats.send.error;
|
---|
[ae020ea] | 86 | uint64_t accp_live = accp_open - accp_clse;
|
---|
[137974ae] | 87 |
|
---|
[32d1383] | 88 | sout | "-----" | time() | "-----";
|
---|
[ae020ea] | 89 | sout | "----- Acceptor Stats -----";
|
---|
[32d1383] | 90 | sout | "accepts : " | eng3(accp_open) |"opened," | eng3(accp_clse) |"closed," | eng3(accp_live) |"live," | eng3(accp_errs) |"errors";
|
---|
[ae020ea] | 91 | sout | "accept : " | eng3(this.stats.accpt.accepts) | "calls," | eng3(this.stats.accpt.eagains) | "eagains," | eng3(this.stats.accpt.creates) | " thrds";
|
---|
| 92 | sout | nl;
|
---|
[137974ae] | 93 |
|
---|
| 94 | sout | "----- Connection Stats -----";
|
---|
[ae020ea] | 95 | sout | "max fd : " | this.stats.send.maxfd;
|
---|
[32d1383] | 96 | sout | "sendfile : " | eng3(calls) | "calls," | eng3(tries) | "tries (" | ratio | " try/call)," | eng3(this.stats.send.eagain) | "eagains";
|
---|
[8419b76] | 97 | sout | " " | eng3(header) | "header," | eng3(splcin) | "splice in," | eng3(splcot) | "splice out";
|
---|
[32d1383] | 98 | // sout | " - zipf sizes:";
|
---|
| 99 | // for(i; zipf_cnts) {
|
---|
| 100 | // double written = avgrd[i].calls > 0 ? ((double)avgrd[i].bytes) / avgrd[i].calls : 0;
|
---|
| 101 | // sout | " " | zipf_sizes[i] | "bytes," | avgrd[i].calls | "shorts," | written | "written";
|
---|
| 102 | // }
|
---|
[137974ae] | 103 | }
|
---|
[ae020ea] | 104 |
|
---|
| 105 | waitfor( ^?{} : this) {
|
---|
| 106 | break LOOP;
|
---|
| 107 | }
|
---|
| 108 | or else {}
|
---|
[137974ae] | 109 | }
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | StatsPrinter * stats_thrd;
|
---|