source: benchmark/io/http/printer.cfa@ c4072d8e

ADT ast-experimental pthread-emulation qualifiedEnum
Last change on this file since c4072d8e was ae020ea, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Printer now prints max fd and open/closed/live connections.

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