Changeset 137974a for benchmark/io/http/worker.cfa
- Timestamp:
- Jun 9, 2022, 10:56:34 AM (8 months ago)
- Branches:
- master, pthread-emulation, qualifiedEnum
- Children:
- 430ce61
- Parents:
- 8c58e73
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/worker.cfa
r8c58e73 r137974a 14 14 #include "filecache.hfa" 15 15 16 void ?{}( sendfile_stats_t & this ) {17 this.calls = 0;18 this.tries = 0;19 this.header = 0;20 this.splcin = 0;21 this.splcot = 0;22 for(i; zipf_cnts) {23 this.avgrd[i].calls = 0;24 this.avgrd[i].bytes = 0;25 }26 }27 28 16 //============================================================================================= 29 17 // Generic connection handling 30 18 //============================================================================================= 31 static void handle_connection( connection & this, volatile int & fd, char * buffer, size_t len, io_future_t * f ) {19 static void handle_connection( connection & this, volatile int & fd, char * buffer, size_t len, io_future_t * f, unsigned long long & last ) { 32 20 REQUEST: 33 21 for() { … … 111 99 if( options.log ) sout | "=== Answer sent ==="; 112 100 } 101 102 if (stats_thrd) { 103 unsigned long long next = rdtscl(); 104 if(next > (last + 500000000)) { 105 if(try_lock(stats_thrd->stats.lock)) { 106 push(this.stats.sendfile, stats_thrd->stats.send); 107 unlock(stats_thrd->stats.lock); 108 last = next; 109 } 110 } 111 } 113 112 } 114 113 … … 124 123 void main( AcceptWorker & this ) { 125 124 park(); 125 unsigned long long last = rdtscl(); 126 126 /* paranoid */ assert( this.conn.pipe[0] != -1 ); 127 127 /* paranoid */ assert( this.conn.pipe[1] != -1 ); … … 139 139 size_t len = options.socket.buflen; 140 140 char buffer[len]; 141 handle_connection( this.conn, fd, buffer, len, 0p );141 handle_connection( this.conn, fd, buffer, len, 0p, last ); 142 142 143 143 if( options.log ) sout | "=== Connection closed ==="; … … 157 157 void main( ChannelWorker & this ) { 158 158 park(); 159 unsigned long long last = rdtscl(); 159 160 /* paranoid */ assert( this.conn.pipe[0] != -1 ); 160 161 /* paranoid */ assert( this.conn.pipe[1] != -1 ); … … 168 169 169 170 if( options.log ) sout | "=== Waiting new connection ==="; 170 handle_connection( this.conn, p.out.fd, buffer, len, &p.f );171 handle_connection( this.conn, p.out.fd, buffer, len, &p.f, last ); 171 172 172 173 if( options.log ) sout | "=== Connection closed ==="; … … 187 188 void main( Acceptor & this ) { 188 189 park(); 190 unsigned long long last = rdtscl(); 189 191 if( options.log ) sout | "=== Accepting connection ==="; 190 192 for() { … … 192 194 if(fd < 0) { 193 195 if( errno == EWOULDBLOCK) { 196 this.stats.eagains++; 194 197 yield(); 195 198 continue; … … 199 202 abort( "accept error: (%d) %s\n", (int)errno, strerror(errno) ); 200 203 } 204 this.stats.accepts++; 205 201 206 if(this.done) return; 202 207 … … 210 215 if(p) break; 211 216 yield(); 217 this.stats.creates++; 212 218 }; 213 219 … … 216 222 } 217 223 224 if (stats_thrd) { 225 unsigned long long next = rdtscl(); 226 if(next > (last + 500000000)) { 227 if(try_lock(stats_thrd->stats.lock)) { 228 push(this.stats, stats_thrd->stats.accpt); 229 unlock(stats_thrd->stats.lock); 230 last = next; 231 } 232 } 233 } 234 218 235 if( options.log ) sout | "=== Accepting connection ==="; 219 236 }
Note: See TracChangeset
for help on using the changeset viewer.