Changeset d11d6eb
- Timestamp:
- Aug 28, 2020, 1:26:28 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:
- 8e3034d
- Parents:
- 8e2cb4a
- Location:
- benchmark/io/http
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/filecache.cfa
r8e2cb4a rd11d6eb 73 73 cache_line * entries; 74 74 size_t size; 75 int * rawfds; 76 int nfds; 75 77 } file_cache; 76 78 … … 98 100 } 99 101 100 int put_file( cache_line & entry ) {102 int put_file( cache_line & entry, int fd ) { 101 103 uint32_t idx = murmur3_32( (const uint8_t *)entry.file, strlen(entry.file), options.file_cache.hash_seed ) % file_cache.size; 102 104 … … 108 110 109 111 file_cache.entries[idx] = entry; 112 file_cache.entries[idx].fd = fd; 110 113 return i > 0 ? 1 : 0; 111 114 } … … 121 124 size_t fcount = 0; 122 125 size_t fsize = 16; 123 cache_line * raw = 0p; 124 raw = alloc(raw, fsize, true); 126 cache_line * raw = alloc(fsize); 125 127 // Step 1 get a dense array of all files 126 128 int walk(const char *fpath, const struct stat *sb, int typeflag) { … … 131 133 if(fcount > fsize) { 132 134 fsize *= 2; 133 raw = alloc( raw, fsize, true);135 raw = alloc(fsize, raw`realloc); 134 136 } 135 137 … … 162 164 file_cache.entries = anew(file_cache.size); 163 165 166 if(options.file_cache.fixed_fds) { 167 file_cache.nfds = fcount; 168 file_cache.rawfds = alloc(fcount); 169 } 170 164 171 // Step 3 fill the cache 165 172 int conflicts = 0; 166 173 for(i; fcount) { 167 conflicts += put_file( raw[i] ); 174 int fd; 175 if(options.file_cache.fixed_fds) { 176 file_cache.rawfds[i] = raw[i].fd; 177 fd = i; 178 } 179 else { 180 fd = raw[i].fd; 181 } 182 conflicts += put_file( raw[i], fd ); 168 183 } 169 184 printf("Filled cache from path \"%s\" with %zu files\n", path, fcount); … … 197 212 } 198 213 199 return [aalloc(extra), 0]; 214 size_t s = file_cache.nfds + extra; 215 int * data = alloc(s, file_cache.rawfds`realloc); 216 return [data, file_cache.nfds]; 200 217 } 201 218 -
benchmark/io/http/main.cfa
r8e2cb4a rd11d6eb 12 12 #include <kernel.hfa> 13 13 #include <stats.hfa> 14 #include <time.hfa> 14 15 #include <thread.hfa> 15 16 … … 18 19 #include "options.hfa" 19 20 #include "worker.hfa" 21 22 extern void register_fixed_files( cluster &, int *, unsigned count ); 23 24 Duration default_preemption() { 25 return 0; 26 } 20 27 21 28 //============================================================================================= … … 84 91 // Run Server Cluster 85 92 { 86 cluster cl = { "Server Cluster", options.clopts. flags };93 cluster cl = { "Server Cluster", options.clopts.params }; 87 94 #if !defined(__CFA_NO_STATISTICS__) 88 95 print_stats_at_exit( cl, CFA_STATS_READY_Q | CFA_STATS_IO ); … … 102 109 } 103 110 111 if(options.file_cache.fixed_fds) { 112 register_fixed_files(cl, fds, pipe_off); 113 } 114 104 115 { 105 116 ServerProc procs[options.clopts.nprocs]; … … 107 118 Worker workers[options.clopts.nworkers]; 108 119 for(i; options.clopts.nworkers) { 109 if( options.file_cache.fixed_fds ) { 110 workers[i].pipe[0] = pipe_off + (i * 2) + 0; 111 workers[i].pipe[1] = pipe_off + (i * 2) + 1; 112 } 113 else { 120 // if( options.file_cache.fixed_fds ) { 121 // workers[i].pipe[0] = pipe_off + (i * 2) + 0; 122 // workers[i].pipe[1] = pipe_off + (i * 2) + 1; 123 // } 124 // else 125 { 114 126 workers[i].pipe[0] = fds[pipe_off + (i * 2) + 0]; 115 127 workers[i].pipe[1] = fds[pipe_off + (i * 2) + 1]; -
benchmark/io/http/options.cfa
r8e2cb4a rd11d6eb 39 39 40 40 const char * parse_options( int argc, char * argv[] ) { 41 bool uthrdpo = false;42 41 bool subthrd = false; 43 42 bool eagrsub = false; … … 57 56 {'C', "cache-size", "Size of the cache to use, if set to small, will uses closes power of 2", options.file_cache.size }, 58 57 {'l', "list-files", "List the files in the specified path and exit", options.file_cache.list, parse_settrue }, 59 {'u', "userthread", "If set, cluster uses user-thread to poll I/O", uthrdpo, parse_settrue },60 58 {'s', "submitthread", "If set, cluster uses polling thread to submit I/O", subthrd, parse_settrue }, 61 59 {'e', "eagersubmit", "If set, cluster submits I/O eagerly but still aggregates submits", eagrsub, parse_settrue}, … … 71 69 parse_args( argc, argv, opt, opt_cnt, "[OPTIONS]... [PATH]\ncforall http server", left ); 72 70 73 if( uthrdpo ) { 74 options.clopts.flags |= CFA_CLUSTER_IO_POLLER_USER_THREAD; 75 } 76 77 if( subthrd ) { 78 options.clopts.flags |= CFA_CLUSTER_IO_POLLER_THREAD_SUBMITS; 79 } 80 81 if( eagrsub ) { 82 options.clopts.flags |= CFA_CLUSTER_IO_EAGER_SUBMITS; 83 } 71 options.clopts.params.poller_submits = subthrd; 72 options.clopts.params.eager_submits = eagrsub; 84 73 85 74 if( fixedfd ) { … … 88 77 89 78 if( sqkpoll ) { 90 options.clopts. flags |= CFA_CLUSTER_IO_KERNEL_POLL_SUBMITS;79 options.clopts.params.poll_submit = true; 91 80 options.file_cache.fixed_fds = true; 92 81 } 93 82 94 83 if( iokpoll ) { 95 options.clopts. flags |= CFA_CLUSTER_IO_KERNEL_POLL_COMPLETES;84 options.clopts.params.poll_complete = true; 96 85 options.file_cache.open_flags |= O_DIRECT; 97 86 } 98 87 99 options.clopts. flags |= (sublen << CFA_CLUSTER_IO_BUFFLEN_OFFSET);88 options.clopts.params.num_ready = sublen; 100 89 101 90 if( left[0] == 0p ) { return "."; } -
benchmark/io/http/options.hfa
r8e2cb4a rd11d6eb 2 2 3 3 #include <stdint.h> 4 5 #include <kernel.hfa> 4 6 5 7 struct cluster; … … 23 25 int nprocs; 24 26 int nworkers; 25 i nt flags;27 io_context_params params; 26 28 int chan_size; 27 29 bool procstats; -
benchmark/io/http/protocol.cfa
r8e2cb4a rd11d6eb 11 11 extern "C" { 12 12 int snprintf ( char * s, size_t n, const char * format, ... ); 13 #include <linux/io_uring.h> 13 14 } 14 15 #include <string.h> 15 16 16 #include <errno.h> 17 17 18 #include "options.hfa" 18 19 19 20 const char * http_msgs[] = { … … 74 75 READ: 75 76 for() { 76 int ret = cfa_read(fd, it, count);77 if(ret == 0 ) return [OK200, true, 0 p, 0];77 int ret = cfa_read(fd, (void*)it, count, 0, -1`s, 0p, 0p); 78 if(ret == 0 ) return [OK200, true, 0, 0]; 78 79 if(ret < 0 ) { 79 80 if( errno == EAGAIN || errno == EWOULDBLOCK) continue READ; … … 88 89 count -= ret; 89 90 90 if( count < 1 ) return [E414, false, 0 p, 0];91 if( count < 1 ) return [E414, false, 0, 0]; 91 92 } 92 93 … … 95 96 it = buffer; 96 97 int ret = memcmp(it, "GET /", 5); 97 if( ret != 0 ) return [E400, false, 0 p, 0];98 if( ret != 0 ) return [E400, false, 0, 0]; 98 99 it += 5; 99 100 … … 106 107 ssize_t ret; 107 108 SPLICE1: while(count > 0) { 108 ret = cfa_splice(ans_fd, &offset, pipe[1], 0p, count, SPLICE_F_MOVE | SPLICE_F_MORE );109 ret = cfa_splice(ans_fd, &offset, pipe[1], 0p, count, SPLICE_F_MOVE | SPLICE_F_MORE, 0, -1`s, 0p, 0p); 109 110 if( ret < 0 ) { 110 111 if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE1; … … 116 117 size_t in_pipe = ret; 117 118 SPLICE2: while(in_pipe > 0) { 118 ret = cfa_splice(pipe[0], 0p, fd, 0p, in_pipe, SPLICE_F_MOVE | SPLICE_F_MORE );119 ret = cfa_splice(pipe[0], 0p, fd, 0p, in_pipe, SPLICE_F_MOVE | SPLICE_F_MORE, 0, -1`s, 0p, 0p); 119 120 if( ret < 0 ) { 120 121 if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE2; -
benchmark/io/http/worker.cfa
r8e2cb4a rd11d6eb 96 96 void main( Acceptor & this ) { 97 97 for() { 98 int ret = cfa_accept4( this.[sockfd, addr, addrlen, flags] );98 int ret = cfa_accept4( this.[sockfd, addr, addrlen, flags], 0, -1`s, 0p, 0p ); 99 99 if(ret < 0) { 100 100 if( errno == ECONNABORTED ) break;
Note: See TracChangeset
for help on using the changeset viewer.