source: benchmark/io/http/printer.cfa@ 137974ae

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

Moved stats printer to it's own file and now using push-stats rather than pull

  • Property mode set to 100644
File size: 3.0 KB
Line 
1#include "printer.hfa"
2
3#include <fstream.hfa>
4#include <stats.hfa>
5
6void ?{}( sendfile_stats_t & this ) {
7 this.calls = 0;
8 this.tries = 0;
9 this.header = 0;
10 this.splcin = 0;
11 this.splcot = 0;
12 for(i; zipf_cnts) {
13 this.avgrd[i].calls = 0;
14 this.avgrd[i].bytes = 0;
15 };
16}
17
18void push(sendfile_stats_t & from, sendfile_stats_t & to) {
19 __atomic_fetch_add(&to.calls, from.calls, __ATOMIC_RELAXED); from.calls = 0;
20 __atomic_fetch_add(&to.tries, from.tries, __ATOMIC_RELAXED); from.tries = 0;
21 __atomic_fetch_add(&to.header, from.header, __ATOMIC_RELAXED); from.header = 0;
22 __atomic_fetch_add(&to.splcin, from.splcin, __ATOMIC_RELAXED); from.splcin = 0;
23 __atomic_fetch_add(&to.splcot, from.splcot, __ATOMIC_RELAXED); from.splcot = 0;
24 for(i; zipf_cnts) {
25 __atomic_fetch_add(&to.avgrd[i].calls, from.avgrd[i].calls, __ATOMIC_RELAXED); from.avgrd[i].calls = 0;
26 __atomic_fetch_add(&to.avgrd[i].bytes, from.avgrd[i].bytes, __ATOMIC_RELAXED); from.avgrd[i].bytes = 0;
27 };
28}
29
30void ?{}( acceptor_stats_t & this ) {
31 this.creates = 0;
32 this.accepts = 0;
33 this.eagains = 0;
34}
35
36void push(acceptor_stats_t & from, acceptor_stats_t & to) {
37 __atomic_fetch_add(&to.creates, from.creates, __ATOMIC_RELAXED); from.creates = 0;
38 __atomic_fetch_add(&to.accepts, from.accepts, __ATOMIC_RELAXED); from.accepts = 0;
39 __atomic_fetch_add(&to.eagains, from.eagains, __ATOMIC_RELAXED); from.eagains = 0;
40}
41
42void ?{}( StatsPrinter & this, cluster & cl ) {
43 ((thread&)this){ "Stats Printer Thread", cl };
44
45 memset(&this.stats, 0, sizeof(this.stats));;
46}
47
48void ^?{}( StatsPrinter & mutex this ) {}
49
50#define eng3(X) (ws(3, 3, unit(eng( X ))))
51
52void main(StatsPrinter & this) {
53 LOOP: for() {
54 waitfor( ^?{} : this) {
55 break LOOP;
56 }
57 or else {}
58
59 wait(this.var, 10`s);
60
61 print_stats_now( *active_cluster(), 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
81 if(this.stats.accpt.accepts > 0) {
82 sout | "----- Acceptor Stats -----";
83 sout | "accept : " | this.stats.accpt.accepts | "calls," | this.stats.accpt.eagains | "eagains," | this.stats.accpt.creates | " thrds";
84 }
85
86 sout | "----- Connection Stats -----";
87 sout | "sendfile : " | calls | "calls," | tries | "tries (" | ratio | " try/call)";
88 sout | " " | header | "header," | splcin | "splice in," | splcot | "splice out";
89 sout | " - zipf sizes:";
90 for(i; zipf_cnts) {
91 double written = avgrd[i].calls > 0 ? ((double)avgrd[i].bytes) / avgrd[i].calls : 0;
92 sout | " " | zipf_sizes[i] | "bytes," | avgrd[i].calls | "shorts," | written | "written";
93 }
94 }
95 }
96}
97
98StatsPrinter * stats_thrd;
Note: See TracBrowser for help on using the repository browser.