#include "printer.hfa" #include #include void ?{}( sendfile_stats_t & this ) { this.calls = 0; this.tries = 0; this.header = 0; this.splcin = 0; this.splcot = 0; for(i; zipf_cnts) { this.avgrd[i].calls = 0; this.avgrd[i].bytes = 0; }; } void push(sendfile_stats_t & from, sendfile_stats_t & to) { __atomic_fetch_add(&to.calls, from.calls, __ATOMIC_RELAXED); from.calls = 0; __atomic_fetch_add(&to.tries, from.tries, __ATOMIC_RELAXED); from.tries = 0; __atomic_fetch_add(&to.header, from.header, __ATOMIC_RELAXED); from.header = 0; __atomic_fetch_add(&to.splcin, from.splcin, __ATOMIC_RELAXED); from.splcin = 0; __atomic_fetch_add(&to.splcot, from.splcot, __ATOMIC_RELAXED); from.splcot = 0; for(i; zipf_cnts) { __atomic_fetch_add(&to.avgrd[i].calls, from.avgrd[i].calls, __ATOMIC_RELAXED); from.avgrd[i].calls = 0; __atomic_fetch_add(&to.avgrd[i].bytes, from.avgrd[i].bytes, __ATOMIC_RELAXED); from.avgrd[i].bytes = 0; }; } void ?{}( acceptor_stats_t & this ) { this.creates = 0; this.accepts = 0; this.eagains = 0; } void push(acceptor_stats_t & from, acceptor_stats_t & to) { __atomic_fetch_add(&to.creates, from.creates, __ATOMIC_RELAXED); from.creates = 0; __atomic_fetch_add(&to.accepts, from.accepts, __ATOMIC_RELAXED); from.accepts = 0; __atomic_fetch_add(&to.eagains, from.eagains, __ATOMIC_RELAXED); from.eagains = 0; } void ?{}( StatsPrinter & this, cluster & cl ) { ((thread&)this){ "Stats Printer Thread", cl }; memset(&this.stats, 0, sizeof(this.stats));; } void ^?{}( StatsPrinter & mutex this ) {} #define eng3(X) (ws(3, 3, unit(eng( X )))) void main(StatsPrinter & this) { LOOP: for() { waitfor( ^?{} : this) { break LOOP; } or else {} wait(this.var, 10`s); print_stats_now( *active_cluster(), CFA_STATS_READY_Q | CFA_STATS_IO ); { struct { volatile uint64_t calls; volatile uint64_t bytes; } avgrd[zipf_cnts]; memset(avgrd, 0, sizeof(avgrd)); uint64_t tries = this.stats.send.tries; uint64_t calls = this.stats.send.calls; uint64_t header = this.stats.send.header; uint64_t splcin = this.stats.send.splcin; uint64_t splcot = this.stats.send.splcot; for(j; zipf_cnts) { avgrd[j].calls += this.stats.send.avgrd[j].calls; avgrd[j].bytes += this.stats.send.avgrd[j].bytes; } double ratio = ((double)tries) / calls; if(this.stats.accpt.accepts > 0) { sout | "----- Acceptor Stats -----"; sout | "accept : " | this.stats.accpt.accepts | "calls," | this.stats.accpt.eagains | "eagains," | this.stats.accpt.creates | " thrds"; } sout | "----- Connection Stats -----"; sout | "sendfile : " | calls | "calls," | tries | "tries (" | ratio | " try/call)"; sout | " " | header | "header," | splcin | "splice in," | splcot | "splice out"; sout | " - zipf sizes:"; for(i; zipf_cnts) { double written = avgrd[i].calls > 0 ? ((double)avgrd[i].bytes) / avgrd[i].calls : 0; sout | " " | zipf_sizes[i] | "bytes," | avgrd[i].calls | "shorts," | written | "written"; } } } } StatsPrinter * stats_thrd;