Changeset 348f81d
- Timestamp:
- Feb 23, 2021, 4:02:27 PM (2 years ago)
- Branches:
- arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b664af2
- Parents:
- a06023f
- Location:
- benchmark/io/http
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/main.cfa
ra06023f r348f81d 29 29 30 30 //============================================================================================= 31 // Globals32 //=============================================================================================33 struct ServerProc {34 processor self;35 };36 37 void ?{}( ServerProc & this ) {38 /* paranoid */ assert( options.clopts.instance != 0p );39 (this.self){ "Benchmark Processor", *options.clopts.instance };40 41 #if !defined(__CFA_NO_STATISTICS__)42 if( options.clopts.procstats ) {43 print_stats_at_exit( this.self, options.clopts.instance->print_stats );44 }45 if( options.clopts.viewhalts ) {46 print_halts( this.self );47 }48 #endif49 }50 51 struct ServerIoContext {52 io_context self;53 };54 55 void ?{}( ServerIoContext & this ) {56 /* paranoid */ assert( options.clopts.instance != 0p );57 (this.self){ *options.clopts.instance };58 }59 60 extern void init_protocol(void);61 extern void deinit_protocol(void);62 63 //=============================================================================================64 31 // Stats Printer 65 32 //=============================================================================================' … … 67 34 thread StatsPrinter {}; 68 35 69 void ?{}( StatsPrinter & this ) {70 ((thread&)this){ "Stats Printer Thread" };36 void ?{}( StatsPrinter & this, cluster & cl ) { 37 ((thread&)this){ "Stats Printer Thread", cl }; 71 38 } 72 39 … … 80 47 sleep(10`s); 81 48 82 print_stats_now( *options.clopts.instance, CFA_STATS_READY_Q | CFA_STATS_IO ); 83 } 84 } 49 print_stats_now( *active_cluster(), CFA_STATS_READY_Q | CFA_STATS_IO ); 50 } 51 } 52 53 //============================================================================================= 54 // Globals 55 //============================================================================================= 56 // struct ServerProc { 57 // processor self; 58 // }; 59 60 // void ?{}( ServerProc & this ) { 61 // /* paranoid */ assert( options.clopts.instance != 0p ); 62 // (this.self){ "Benchmark Processor", *options.clopts.instance }; 63 64 // #if !defined(__CFA_NO_STATISTICS__) 65 // if( options.clopts.procstats ) { 66 // print_stats_at_exit( this.self, options.clopts.instance->print_stats ); 67 // } 68 // if( options.clopts.viewhalts ) { 69 // print_halts( this.self ); 70 // } 71 // #endif 72 // } 73 74 // struct ServerIoContext { 75 // io_context self; 76 // }; 77 78 // void ?{}( ServerIoContext & this ) { 79 // /* paranoid */ assert( options.clopts.instance != 0p ); 80 // (this.self){ *options.clopts.instance }; 81 // } 82 83 struct ServerCluster { 84 cluster self; 85 processor * procs; 86 io_context * ctxs; 87 StatsPrinter * prnt; 88 89 }; 90 91 void ?{}( ServerCluster & this ) { 92 (this.self){ "Server Cluster", options.clopts.params }; 93 94 this.procs = alloc(options.clopts.nprocs); 95 for(i; options.clopts.nprocs) { 96 (this.procs[i]){ "Benchmark Processor", this.self }; 97 98 #if !defined(__CFA_NO_STATISTICS__) 99 if( options.clopts.procstats ) { 100 print_stats_at_exit( *this.procs, this.self.print_stats ); 101 } 102 if( options.clopts.viewhalts ) { 103 print_halts( *this.procs ); 104 } 105 #endif 106 } 107 108 this.ctxs = alloc(options.clopts.nprocs); 109 for(i; options.clopts.nprocs) { 110 (this.ctxs[i]){ this.self }; 111 } 112 113 this.prnt = alloc(options.clopts.nprocs); 114 for(i; options.clopts.nprocs) { 115 (this.prnt[i]){ this.self }; 116 } 117 118 #if !defined(__CFA_NO_STATISTICS__) 119 print_stats_at_exit( this.self, CFA_STATS_READY_Q | CFA_STATS_IO ); 120 #endif 121 122 options.clopts.instance[options.clopts.cltr_cnt] = &this.self; 123 options.clopts.cltr_cnt++; 124 } 125 126 void ^?{}( ServerCluster & this ) { 127 for(i; options.clopts.nprocs) { 128 ^(this.prnt[i]){}; 129 } 130 free(this.prnt); 131 132 for(i; options.clopts.nprocs) { 133 ^(this.ctxs[i]){}; 134 } 135 free(this.ctxs); 136 137 for(i; options.clopts.nprocs) { 138 ^(this.procs[i]){}; 139 } 140 free(this.procs); 141 142 ^(this.self){}; 143 } 144 145 extern void init_protocol(void); 146 extern void deinit_protocol(void); 85 147 86 148 //============================================================================================= … … 146 208 // Run Server Cluster 147 209 { 148 cluster cl = { "Server Cluster", options.clopts.params };149 #if !defined(__CFA_NO_STATISTICS__)150 print_stats_at_exit( cl, CFA_STATS_READY_Q | CFA_STATS_IO );151 #endif152 options.clopts.instance = &cl;153 154 155 210 int pipe_cnt = options.clopts.nworkers * 2; 156 211 int pipe_off; … … 167 222 168 223 { 169 ServerProc procs[options.clopts.nprocs]; 170 ServerIoContext ioctxs[options.clopts.nprocs]; 171 // StatsPrinter printer; 224 ServerCluster cl[options.clopts.nclusters]; 172 225 173 226 init_protocol(); … … 190 243 unpark( workers[i] ); 191 244 } 192 sout | options.clopts.nworkers | "workers started on" | options.clopts.nprocs | "processors"; 245 sout | options.clopts.nworkers | "workers started on" | options.clopts.nprocs | "processors /" | options.clopts.nclusters | "clusters"; 246 for(i; options.clopts.nclusters) { 247 sout | options.clopts.thrd_cnt[i] | nonl; 248 } 249 sout | nl; 193 250 { 194 251 char buffer[128]; … … 230 287 sout | "done"; 231 288 232 sout | "Stopping processors ..." | nonl; flush( sout );289 sout | "Stopping processors/clusters..." | nonl; flush( sout ); 233 290 } 234 291 sout | "done"; -
benchmark/io/http/options.cfa
ra06023f r348f81d 13 13 #include <kernel.hfa> 14 14 #include <parseargs.hfa> 15 #include <stdlib.hfa> 15 16 16 17 #include <stdlib.h> … … 36 37 37 38 { // cluster 39 1, // nclusters; 38 40 1, // nprocs; 39 41 1, // nworkers; … … 50 52 // bool iokpoll = false; 51 53 unsigned nentries = 16; 54 bool isolate = false; 52 55 53 56 … … 56 59 { 'c', "cpus", "Number of processors to use", options.clopts.nprocs}, 57 60 { 't', "threads", "Number of worker threads to use", options.clopts.nworkers}, 61 {'\0', "isolate", "Create one cluster per processor", isolate, parse_settrue}, 58 62 {'\0', "log", "Enable logs", options.log, parse_settrue}, 59 63 {'\0', "accept-backlog", "Maximum number of pending accepts", options.socket.backlog}, … … 85 89 nentries = v; 86 90 } 91 if(isolate) { 92 options.clopts.nclusters = options.clopts.nprocs; 93 options.clopts.nprocs = 1; 94 } 87 95 options.clopts.params.num_entries = nentries; 96 options.clopts.instance = alloc(options.clopts.nclusters); 97 options.clopts.thrd_cnt = alloc(options.clopts.nclusters); 98 options.clopts.cltr_cnt = 0; 99 for(i; options.clopts.nclusters) { 100 options.clopts.thrd_cnt[i] = 0; 101 } 102 88 103 89 104 // if( fixedfd ) { -
benchmark/io/http/options.hfa
ra06023f r348f81d 26 26 27 27 struct { 28 int nclusters; 28 29 int nprocs; 29 30 int nworkers; … … 31 32 bool procstats; 32 33 bool viewhalts; 33 cluster * instance; 34 cluster ** instance; 35 size_t * thrd_cnt; 36 size_t cltr_cnt; 34 37 } clopts; 35 38 }; -
benchmark/io/http/protocol.cfa
ra06023f r348f81d 182 182 183 183 void ?{}( DateFormater & this ) { 184 ((thread&)this){ "Server Date Thread", *options.clopts.instance };184 ((thread&)this){ "Server Date Thread", *options.clopts.instance[0] }; 185 185 this.idx = 0; 186 186 memset( this.buffers[0].buff, 0, sizeof(this.buffers[0]) ); -
benchmark/io/http/worker.cfa
ra06023f r348f81d 17 17 //============================================================================================= 18 18 void ?{}( Worker & this ) { 19 ((thread&)this){ "Server Worker Thread", *options.clopts.instance }; 19 size_t cli = rand() % options.clopts.cltr_cnt; 20 ((thread&)this){ "Server Worker Thread", *options.clopts.instance[cli] }; 21 options.clopts.thrd_cnt[cli]++; 20 22 this.pipe[0] = -1; 21 23 this.pipe[1] = -1;
Note: See TracChangeset
for help on using the changeset viewer.