Changeset 71cf630 for benchmark/io/http/worker.cfa
- Timestamp:
- Aug 16, 2022, 4:04:47 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- aec2c022
- Parents:
- 741e22c (diff), 17c6edeb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/worker.cfa
r741e22c r71cf630 14 14 #include "filecache.hfa" 15 15 16 static const unsigned long long period = 5 0_000_000;16 static const unsigned long long period = 5_000_000; 17 17 18 18 //============================================================================================= … … 33 33 34 34 // if we are done, break out of the loop 35 if( closed ) break REQUEST; 35 if( closed ) { 36 if( code != OK200 ) this.stats.sendfile.error++; 37 break REQUEST; 38 } 36 39 37 40 // If this wasn't a request retrun 400 38 41 if( code != OK200 ) { 39 sout | "=== Invalid Request :" | code_val(code) | "===";40 answer_error(fd, code);41 continue REQUEST;42 } 43 44 if(0 == strncmp(file, "plaintext", min(name_size, sizeof("plaintext") ))) {45 if( options.log ) mutex(sout) sout | "=== Request for /plaintext ===";46 47 int ret = answer_plaintext(fd);48 if( ret == -ECONNRESET ) break REQUEST;49 50 if( options.log ) mutex(sout) sout | "=== Answer sent ===";51 continue REQUEST;52 }53 54 if(0 == strncmp(file, "ping", min(name_size, sizeof("ping") ))) {55 if( options.log ) mutex(sout) sout | "=== Request for /ping ===";56 57 // Send the header58 int ret = answer_empty(fd);59 if( ret == -ECONNRESET ) break REQUEST;60 61 if( options.log ) mutex(sout) sout | "=== Answer sent ===";62 continue REQUEST;63 }42 abort | "=== Invalid Request :" | code_val(code) | "==="; 43 // answer_error(fd, code); 44 // continue REQUEST; 45 } 46 47 // if(0 == strncmp(file, "plaintext", min(name_size, sizeof("plaintext") ))) { 48 // if( options.log ) mutex(sout) sout | "=== Request for /plaintext ==="; 49 50 // int ret = answer_plaintext(fd); 51 // if( ret == -ECONNRESET ) { this.stats.sendfile.error++; break REQUEST; } 52 53 // if( options.log ) mutex(sout) sout | "=== Answer sent ==="; 54 // continue REQUEST; 55 // } 56 57 // if(0 == strncmp(file, "ping", min(name_size, sizeof("ping") ))) { 58 // if( options.log ) mutex(sout) sout | "=== Request for /ping ==="; 59 60 // // Send the header 61 // int ret = answer_empty(fd); 62 // if( ret == -ECONNRESET ) { this.stats.sendfile.error++; break REQUEST; } 63 64 // if( options.log ) mutex(sout) sout | "=== Answer sent ==="; 65 // continue REQUEST; 66 // } 64 67 65 68 if( options.log ) { … … 70 73 71 74 if( !options.file_cache.path ) { 72 if( options.log ) { 73 sout | "=== File Not Found (" | nonl; 74 write(sout, file, name_size); 75 sout | ") ==="; 76 } 77 answer_error(fd, E405); 78 continue REQUEST; 75 // if( options.log ) { 76 serr | "=== File Not Found (" | nonl; 77 write(serr, file, name_size); 78 serr | ") ==="; 79 abort(); 80 // } 81 // answer_error(fd, E405); 82 // continue REQUEST; 79 83 } 80 84 … … 86 90 // If we can't find the file, return 404 87 91 if( ans_fd < 0 ) { 88 if( options.log ) { 89 sout | "=== File Not Found (" | nonl; 90 write(sout, file, name_size); 91 sout | ") ==="; 92 } 93 answer_error(fd, E404); 94 continue REQUEST; 92 // if( options.log ) { 93 serr | "=== File Not Found 2 (" | nonl; 94 write(serr, file, name_size); 95 serr | ") ==="; 96 abort(); 97 // } 98 // answer_error(fd, E404); 99 // continue REQUEST; 95 100 } 96 101 … … 98 103 int ret = answer_sendfile( this.pipe, fd, ans_fd, count, this.stats.sendfile ); 99 104 if(ret < 0) { 100 if( ret == -ECONNABORTED ) break REQUEST; 101 if( ret == -ECONNRESET ) break REQUEST; 102 if( ret == -EPIPE ) break REQUEST; 103 abort( "sendfile error: %d (%d) %s\n", ret, (int)errno, strerror(errno) ); 105 if( ret == -ECONNABORTED ) { this.stats.sendfile.error++; break REQUEST; } 106 if( ret == -ECONNRESET ) { this.stats.sendfile.error++; break REQUEST; } 107 if( ret == -EPIPE ) { this.stats.sendfile.error++; break REQUEST; } 108 if( ret == -EBADF ) { this.stats.sendfile.error++; break REQUEST; } 109 abort( "answer sendfile error: %d (%d) %s\n", ret, (int)errno, strerror(errno) ); 104 110 } 105 111 … … 107 113 } 108 114 115 this.stats.sendfile.close++; 116 109 117 if (stats_thrd) { 110 unsigned long long next = rdtscl();111 if(next > (last + period)) {118 // unsigned long long next = rdtscl(); 119 // if(next > (last + period)) { 112 120 if(try_lock(stats_thrd->stats.lock __cfaabi_dbg_ctx2)) { 113 121 push(this.stats.sendfile, stats_thrd->stats.send); 114 122 unlock(stats_thrd->stats.lock); 115 last = next;116 } 117 }123 // last = next; 124 } 125 // } 118 126 } 119 127 } … … 144 152 if(this.done) break; 145 153 154 this.stats.accepts++; 155 if (stats_thrd && try_lock(stats_thrd->stats.lock)) { 156 push(this.stats, stats_thrd->stats.accpt); 157 unlock(stats_thrd->stats.lock); 158 } 159 146 160 if( options.log ) mutex(sout) sout | "=== New connection" | fd | "" | ", waiting for requests ==="; 147 161 size_t len = options.socket.buflen; … … 149 163 handle_connection( this.conn, fd, buffer, len, 0p, last ); 150 164 this.conn.stats.sendfile.maxfd = max(this.conn.stats.sendfile.maxfd, fd); 151 this.conn.stats.sendfile.close++;152 165 153 166 if( options.log ) mutex(sout) sout | "=== Connection closed ==="; … … 172 185 /* paranoid */ assert( this.conn.pipe[1] != -1 ); 173 186 this.conn.stats.sendfile.maxfd = max(this.conn.pipe[0], this.conn.pipe[1]); 187 // this.conn.stats.sendfile.maxfd = 0; 174 188 for() { 175 189 size_t len = options.socket.buflen; … … 220 234 p = pop(*this.queue); 221 235 if(p) break; 236 // abort( "Too few threads" ); 222 237 yield(); 223 238 this.stats.creates++; … … 288 303 289 304 if (stats_thrd) { 290 unsigned long long next = rdtscl();291 if(next > (last + period)) {305 // unsigned long long next = rdtscl(); 306 // if(next > (last + period)) { 292 307 if(try_lock(stats_thrd->stats.lock)) { 293 308 push(this.stats, stats_thrd->stats.accpt); 294 309 unlock(stats_thrd->stats.lock); 295 last = next;310 // last = next; 296 311 } 297 }312 // } 298 313 } 299 314
Note: See TracChangeset
for help on using the changeset viewer.