Changeset 137974ae for benchmark/io/http/main.cfa
- Timestamp:
- Jun 9, 2022, 10:56:34 AM (2 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 430ce61
- Parents:
- 8c58e73
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/main.cfa
r8c58e73 r137974ae 25 25 #include "options.hfa" 26 26 #include "socket.hfa" 27 #include "printer.hfa" 27 28 #include "worker.hfa" 28 29 … … 31 32 Duration default_preemption() { 32 33 return 0; 33 }34 35 //=============================================================================================36 // Stats Printer37 //============================================================================================='38 39 thread StatsPrinter {40 connection ** conns;41 volatile int conn_cnt;42 condition_variable(fast_block_lock) var;43 };44 45 void ?{}( StatsPrinter & this, cluster & cl ) {46 ((thread&)this){ "Stats Printer Thread", cl };47 this.conn_cnt = 0;48 }49 50 void ^?{}( StatsPrinter & mutex this ) {}51 52 #define eng3(X) (ws(3, 3, unit(eng( X ))))53 54 void main(StatsPrinter & this) {55 LOOP: for() {56 waitfor( ^?{} : this) {57 break LOOP;58 }59 or else {}60 61 wait(this.var, 10`s);62 63 print_stats_now( *active_cluster(), CFA_STATS_READY_Q | CFA_STATS_IO );64 if(this.conn_cnt != 0) {65 uint64_t tries = 0;66 uint64_t calls = 0;67 uint64_t header = 0;68 uint64_t splcin = 0;69 uint64_t splcot = 0;70 struct {71 volatile uint64_t calls;72 volatile uint64_t bytes;73 } avgrd[zipf_cnts];74 memset(avgrd, 0, sizeof(avgrd));75 76 for(i; this.conn_cnt) {77 tries += this.conns[i]->stats.sendfile.tries;78 calls += this.conns[i]->stats.sendfile.calls;79 header += this.conns[i]->stats.sendfile.header;80 splcin += this.conns[i]->stats.sendfile.splcin;81 splcot += this.conns[i]->stats.sendfile.splcot;82 for(j; zipf_cnts) {83 avgrd[j].calls += this.conns[i]->stats.sendfile.avgrd[j].calls;84 avgrd[j].bytes += this.conns[i]->stats.sendfile.avgrd[j].bytes;85 }86 }87 88 double ratio = ((double)tries) / calls;89 90 sout | "----- Connection Stats -----";91 sout | "sendfile : " | calls | "calls," | tries | "tries (" | ratio | " try/call)";92 sout | " " | header | "header," | splcin | "splice in," | 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 else {100 sout | "No Connections!";101 }102 }103 34 } 104 35 … … 109 40 cluster self; 110 41 processor * procs; 111 // io_context * ctxs;112 StatsPrinter * prnt;113 42 114 43 }; … … 152 81 } 153 82 154 if(options.stats) {155 this.prnt = alloc();156 (*this.prnt){ this.self };157 } else {158 this.prnt = 0p;159 }160 161 83 #if !defined(__CFA_NO_STATISTICS__) 162 84 print_stats_at_exit( this.self, CFA_STATS_READY_Q | CFA_STATS_IO ); … … 167 89 168 90 void ^?{}( ServerCluster & this ) { 169 delete(this.prnt);170 171 91 for(i; options.clopts.nprocs) { 172 92 ^(this.procs[i]){}; … … 268 188 Q * queues = 0p; 269 189 ServerCluster cl; 190 191 if(options.stats) { 192 stats_thrd = alloc(); 193 (*stats_thrd){ cl.self }; 194 } else { 195 stats_thrd = 0p; 196 } 270 197 271 198 init_protocol(); … … 319 246 } 320 247 } 321 cl.prnt->conns = conns; 322 cl.prnt->conn_cnt = options.clopts.nworkers; 248 323 249 sout | options.clopts.nworkers | "workers started on" | options.clopts.nprocs | "processors"; 324 250 sout | nl; … … 436 362 437 363 sout | "Stopping printer threads..." | nonl; flush( sout ); 438 StatsPrinter * p = cl.prnt; 439 if(p) { 440 notify_one(p->var); 441 join(*p); 442 } 364 if(stats_thrd) { 365 notify_one(stats_thrd->var); 366 } 367 delete(stats_thrd); 443 368 sout | "done"; 444 369
Note: See TracChangeset
for help on using the changeset viewer.