Changeset 4f762d3 for benchmark/io/http
- Timestamp:
- Feb 19, 2021, 1:48:14 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:
- d60d30e
- Parents:
- 78da4ab
- Location:
- benchmark/io/http
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/main.cfa
r78da4ab r4f762d3 47 47 } 48 48 #endif 49 } 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 }; 49 58 } 50 59 … … 153 162 } 154 163 155 if(options.file_cache.path && options.file_cache.fixed_fds) {156 register_fixed_files(cl, fds, pipe_off);157 }164 // if(options.file_cache.path && options.file_cache.fixed_fds) { 165 // register_fixed_files(cl, fds, pipe_off); 166 // } 158 167 159 168 { 160 169 ServerProc procs[options.clopts.nprocs]; 161 StatsPrinter printer; 170 ServerIoContext ioctxs[options.clopts.nprocs]; 171 // StatsPrinter printer; 162 172 163 173 init_protocol(); … … 183 193 { 184 194 char buffer[128]; 185 while(int ret = cfa_read(0, buffer, 128, 0 , -1`s, 0p, 0p); ret != 0) {195 while(int ret = cfa_read(0, buffer, 128, 0); ret != 0) { 186 196 if(ret < 0) abort( "main read error: (%d) %s\n", (int)errno, strerror(errno) ); 187 197 } … … 193 203 for(i; options.clopts.nworkers) { 194 204 workers[i].done = true; 195 cancel(workers[i].cancel);196 205 } 197 206 sout | "done"; -
benchmark/io/http/options.cfa
r78da4ab r4f762d3 46 46 47 47 void parse_options( int argc, char * argv[] ) { 48 bool subthrd = false; 49 bool eagrsub = false; 50 bool fixedfd = false; 51 bool sqkpoll = false; 52 bool iokpoll = false; 53 unsigned sublen = 16; 48 // bool fixedfd = false; 49 // bool sqkpoll = false; 50 // bool iokpoll = false; 54 51 unsigned nentries = 16; 55 52 … … 65 62 {'\0', "cache-size", "Size of the cache to use, if set to small, will uses closes power of 2", options.file_cache.size }, 66 63 {'\0', "list-files", "List the files in the specified path and exit", options.file_cache.list, parse_settrue }, 67 { 's', "submitthread", "If set, cluster uses polling thread to submit I/O", subthrd, parse_settrue }, 68 { 'e', "eagersubmit", "If set, cluster submits I/O eagerly but still aggregates submits", eagrsub, parse_settrue}, 69 { 'f', "fixed-fds", "If set, files are open eagerly and pre-registered with the cluster", fixedfd, parse_settrue}, 70 { 'k', "kpollsubmit", "If set, cluster uses IORING_SETUP_SQPOLL, implies -f", sqkpoll, parse_settrue }, 71 { 'i', "kpollcomplete", "If set, cluster uses IORING_SETUP_IOPOLL", iokpoll, parse_settrue }, 72 {'\0', "submitlength", "Max number of submitions that can be submitted together", sublen }, 64 // { 'f', "fixed-fds", "If set, files are open eagerly and pre-registered with the cluster", fixedfd, parse_settrue}, 65 // { 'k', "kpollsubmit", "If set, cluster uses IORING_SETUP_SQPOLL, implies -f", sqkpoll, parse_settrue }, 66 // { 'i', "kpollcomplete", "If set, cluster uses IORING_SETUP_IOPOLL", iokpoll, parse_settrue }, 73 67 {'\0', "numentries", "Number of I/O entries", nentries }, 74 68 … … 93 87 options.clopts.params.num_entries = nentries; 94 88 95 options.clopts.params.poller_submits = subthrd; 96 options.clopts.params.eager_submits = eagrsub; 89 // if( fixedfd ) { 90 // options.file_cache.fixed_fds = true; 91 // } 97 92 98 if( fixedfd) {99 options.file_cache.fixed_fds = true;100 }93 // if( sqkpoll ) { 94 // options.file_cache.fixed_fds = true; 95 // } 101 96 102 if( sqkpoll ) { 103 options.clopts.params.poll_submit = true; 104 options.file_cache.fixed_fds = true; 105 } 106 107 if( iokpoll ) { 108 options.clopts.params.poll_complete = true; 109 options.file_cache.open_flags |= O_DIRECT; 110 } 111 112 options.clopts.params.num_ready = sublen; 97 // if( iokpoll ) { 98 // options.file_cache.open_flags |= O_DIRECT; 99 // } 113 100 114 101 if( left[0] == 0p ) { return; } -
benchmark/io/http/protocol.cfa
r78da4ab r4f762d3 53 53 while(len > 0) { 54 54 // Call write 55 int ret = cfa_write(fd, it, len, 0, -1`s, 0p, 0p); 56 // int ret = write(fd, it, len); 55 int ret = cfa_send(fd, it, len, 0, 0); 57 56 if( ret < 0 ) { 58 57 if( errno == ECONNRESET || errno == EPIPE ) return -ECONNRESET; … … 94 93 95 94 96 [HttpCode code, bool closed, * const char file, size_t len] http_read(int fd, []char buffer, size_t len , io_cancellation * cancel) {95 [HttpCode code, bool closed, * const char file, size_t len] http_read(int fd, []char buffer, size_t len) { 97 96 char * it = buffer; 98 97 size_t count = len - 1; … … 100 99 READ: 101 100 for() { 102 int ret = cfa_re ad(fd, (void*)it, count, 0, -1`s, cancel, 0p);101 int ret = cfa_recv(fd, (void*)it, count, 0, 0); 103 102 // int ret = read(fd, (void*)it, count); 104 103 if(ret == 0 ) return [OK200, true, 0, 0]; … … 139 138 ssize_t ret; 140 139 SPLICE1: while(count > 0) { 141 ret = cfa_splice(ans_fd, &offset, pipe[1], 0p, count, sflags, 0 , -1`s, 0p, 0p);140 ret = cfa_splice(ans_fd, &offset, pipe[1], 0p, count, sflags, 0); 142 141 // ret = splice(ans_fd, &offset, pipe[1], 0p, count, sflags); 143 142 if( ret < 0 ) { … … 152 151 size_t in_pipe = ret; 153 152 SPLICE2: while(in_pipe > 0) { 154 ret = cfa_splice(pipe[0], 0p, fd, 0p, in_pipe, sflags, 0 , -1`s, 0p, 0p);153 ret = cfa_splice(pipe[0], 0p, fd, 0p, in_pipe, sflags, 0); 155 154 // ret = splice(pipe[0], 0p, fd, 0p, in_pipe, sflags); 156 155 if( ret < 0 ) { -
benchmark/io/http/protocol.hfa
r78da4ab r4f762d3 1 1 #pragma once 2 3 struct io_cancellation;4 2 5 3 enum HttpCode { … … 21 19 int answer_empty( int fd ); 22 20 23 [HttpCode code, bool closed, * const char file, size_t len] http_read(int fd, []char buffer, size_t len , io_cancellation *);21 [HttpCode code, bool closed, * const char file, size_t len] http_read(int fd, []char buffer, size_t len); 24 22 25 23 int sendfile( int pipe[2], int fd, int ans_fd, size_t count ); -
benchmark/io/http/worker.cfa
r78da4ab r4f762d3 35 35 for() { 36 36 if( options.log ) sout | "=== Accepting connection ==="; 37 int fd = cfa_accept4( this.[sockfd, addr, addrlen, flags], 0, -1`s, &this.cancel, 0p ); 38 // int fd = accept4( this.[sockfd, addr, addrlen, flags] ); 37 int fd = cfa_accept4( this.[sockfd, addr, addrlen, flags], 0 ); 39 38 if(fd < 0) { 40 39 if( errno == ECONNABORTED ) break; … … 42 41 abort( "accept error: (%d) %s\n", (int)errno, strerror(errno) ); 43 42 } 43 if(this.done) break; 44 44 45 45 if( options.log ) sout | "=== New connection" | fd | "" | ", waiting for requests ==="; … … 55 55 char buffer[len]; 56 56 if( options.log ) sout | "=== Reading request ==="; 57 [code, closed, file, name_size] = http_read(fd, buffer, len , &this.cancel);57 [code, closed, file, name_size] = http_read(fd, buffer, len); 58 58 59 59 // if we are done, break out of the loop -
benchmark/io/http/worker.hfa
r78da4ab r4f762d3 17 17 socklen_t * addrlen; 18 18 int flags; 19 io_cancellation cancel;20 19 volatile bool done; 21 20 };
Note: See TracChangeset
for help on using the changeset viewer.