source: benchmark/io/http/printer.cfa@ 07997cd

ADT ast-experimental pthread-emulation qualifiedEnum stuck-waitfor-destruct
Last change on this file since 07997cd was 8419b76, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

printer now properly uses eng3

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