Changeset 2cd784a
- Timestamp:
- Mar 2, 2021, 1:59:38 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- d5006b1
- Parents:
- dddb3dd0
- Location:
- benchmark/io/http
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/main.cfa
rdddb3dd0 r2cd784a 38 38 } 39 39 40 void ^?{}( StatsPrinter & mutex this ) {} 41 40 42 void main(StatsPrinter & this) { 41 43 LOOP: for() { … … 54 56 // Globals 55 57 //============================================================================================= 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 // #endif72 // }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 58 struct ServerCluster { 84 59 cluster self; 85 60 processor * procs; 86 io_context * ctxs;61 // io_context * ctxs; 87 62 StatsPrinter * prnt; 88 63 … … 106 81 } 107 82 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 }; 83 if(options.stats) { 84 this.prnt = alloc(); 85 (*this.prnt){ this.self }; 86 } else { 87 this.prnt = 0p; 116 88 } 117 89 … … 125 97 126 98 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); 99 delete(this.prnt); 136 100 137 101 for(i; options.clopts.nprocs) { … … 250 214 { 251 215 char buffer[128]; 252 while(int ret = cfa_read(0, buffer, 128, 0); ret != 0) { 216 for() { 217 int ret = cfa_read(0, buffer, 128, 0); 218 if(ret == 0) break; 253 219 if(ret < 0) abort( "main read error: (%d) %s\n", (int)errno, strerror(errno) ); 220 sout | "User wrote '" | "" | nonl; 221 write(sout, buffer, ret - 1); 222 sout | "'"; 254 223 } 255 224 -
benchmark/io/http/options.cfa
rdddb3dd0 r2cd784a 20 20 Options options @= { 21 21 false, // log 22 false, // stats 22 23 23 24 { // file_cache … … 61 62 {'\0', "isolate", "Create one cluster per processor", isolate, parse_settrue}, 62 63 {'\0', "log", "Enable logs", options.log, parse_settrue}, 64 {'\0', "stats", "Enable statistics", options.stats, parse_settrue}, 63 65 {'\0', "accept-backlog", "Maximum number of pending accepts", options.socket.backlog}, 64 66 {'\0', "request_len", "Maximum number of bytes in the http request, requests with more data will be answered with Http Code 414", options.socket.buflen}, -
benchmark/io/http/options.hfa
rdddb3dd0 r2cd784a 9 9 struct Options { 10 10 bool log; 11 bool stats; 11 12 12 13 struct { -
benchmark/io/http/protocol.cfa
rdddb3dd0 r2cd784a 52 52 while(len > 0) { 53 53 // Call write 54 int ret = cfa_send(fd, it, len, 0, 0);54 int ret = cfa_send(fd, it, len, 0, CFA_IO_LAZY); 55 55 if( ret < 0 ) { 56 56 if( errno == ECONNRESET || errno == EPIPE ) return -ECONNRESET; … … 121 121 READ: 122 122 for() { 123 int ret = cfa_recv(fd, (void*)it, count, 0, 0);123 int ret = cfa_recv(fd, (void*)it, count, 0, CFA_IO_LAZY); 124 124 // int ret = read(fd, (void*)it, count); 125 125 if(ret == 0 ) return [OK200, true, 0, 0]; … … 160 160 ssize_t ret; 161 161 SPLICE1: while(count > 0) { 162 ret = cfa_splice(ans_fd, &offset, pipe[1], 0p, count, sflags, 0); 163 // ret = splice(ans_fd, &offset, pipe[1], 0p, count, sflags); 162 ret = cfa_splice(ans_fd, &offset, pipe[1], 0p, count, sflags, CFA_IO_LAZY); 164 163 if( ret < 0 ) { 165 164 if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE1; … … 173 172 size_t in_pipe = ret; 174 173 SPLICE2: while(in_pipe > 0) { 175 ret = cfa_splice(pipe[0], 0p, fd, 0p, in_pipe, sflags, 0); 176 // ret = splice(pipe[0], 0p, fd, 0p, in_pipe, sflags); 174 ret = cfa_splice(pipe[0], 0p, fd, 0p, in_pipe, sflags, CFA_IO_LAZY); 177 175 if( ret < 0 ) { 178 176 if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE2; … … 232 230 Time now = getTimeNsec(); 233 231 strftime( buff, 100, "%a, %d %b %Y %H:%M:%S %Z", now ); 232 sout | "Updated date to '" | buff | "'"; 234 233 235 234 for(i; KNOWN_CODES) { … … 244 243 this.idx = (this.idx + 1) % 2; 245 244 245 sout | "Date thread sleeping"; 246 246 247 sleep(1`s); 247 248 } -
benchmark/io/http/worker.cfa
rdddb3dd0 r2cd784a 37 37 for() { 38 38 if( options.log ) sout | "=== Accepting connection ==="; 39 int fd = cfa_accept4( this.[sockfd, addr, addrlen, flags], 0);39 int fd = cfa_accept4( this.[sockfd, addr, addrlen, flags], CFA_IO_LAZY ); 40 40 if(fd < 0) { 41 41 if( errno == ECONNABORTED ) break;
Note: See TracChangeset
for help on using the changeset viewer.