source: benchmark/io/http/options.cfa@ 348f81d5

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 348f81d5 was 348f81d5, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Added option to isolate processor so everything has it's own cluster

  • Property mode set to 100644
File size: 3.5 KB
Line 
1#include "options.hfa"
2
3#define _GNU_SOURCE
4#define __USE_GNU
5extern "C" {
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9}
10
11#include <bitmanip.hfa>
12#include <fstream.hfa>
13#include <kernel.hfa>
14#include <parseargs.hfa>
15#include <stdlib.hfa>
16
17#include <stdlib.h>
18#include <string.h>
19
20Options options @= {
21 false, // log
22
23 { // file_cache
24 0, // path
25 0, // open_flags;
26 42u, // hash_seed;
27 0, // size;
28 false, // list;
29 false // fixed_fds
30 },
31
32 { // socket
33 8080, // port
34 10, // backlog
35 1024 // buflen
36 },
37
38 { // cluster
39 1, // nclusters;
40 1, // nprocs;
41 1, // nworkers;
42 {}, // params;
43 false, // procstats
44 false, // viewhalts
45 0, // instance;
46 }
47};
48
49void parse_options( int argc, char * argv[] ) {
50 // bool fixedfd = false;
51 // bool sqkpoll = false;
52 // bool iokpoll = false;
53 unsigned nentries = 16;
54 bool isolate = false;
55
56
57 static cfa_option opt[] = {
58 { 'p', "port", "Port the server will listen on", options.socket.port},
59 { 'c', "cpus", "Number of processors to use", options.clopts.nprocs},
60 { 't', "threads", "Number of worker threads to use", options.clopts.nworkers},
61 {'\0', "isolate", "Create one cluster per processor", isolate, parse_settrue},
62 {'\0', "log", "Enable logs", options.log, parse_settrue},
63 {'\0', "accept-backlog", "Maximum number of pending accepts", options.socket.backlog},
64 {'\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},
65 {'\0', "seed", "seed to use for hashing", options.file_cache.hash_seed },
66 {'\0', "cache-size", "Size of the cache to use, if set to small, will uses closes power of 2", options.file_cache.size },
67 {'\0', "list-files", "List the files in the specified path and exit", options.file_cache.list, parse_settrue },
68 // { 'f', "fixed-fds", "If set, files are open eagerly and pre-registered with the cluster", fixedfd, parse_settrue},
69 // { 'k', "kpollsubmit", "If set, cluster uses IORING_SETUP_SQPOLL, implies -f", sqkpoll, parse_settrue },
70 // { 'i', "kpollcomplete", "If set, cluster uses IORING_SETUP_IOPOLL", iokpoll, parse_settrue },
71 {'e', "numentries", "Number of I/O entries", nentries },
72
73 };
74 int opt_cnt = sizeof(opt) / sizeof(cfa_option);
75
76 char **left;
77 parse_args( argc, argv, opt, opt_cnt, "[OPTIONS]... [PATH]\ncforall http server", left );
78
79 if( !is_pow2(nentries) ) {
80 unsigned v = nentries;
81 v--;
82 v |= v >> 1;
83 v |= v >> 2;
84 v |= v >> 4;
85 v |= v >> 8;
86 v |= v >> 16;
87 v++;
88 serr | "Warning: num_entries not a power of 2" | '(' | nentries | ')' | "raising to " | v;
89 nentries = v;
90 }
91 if(isolate) {
92 options.clopts.nclusters = options.clopts.nprocs;
93 options.clopts.nprocs = 1;
94 }
95 options.clopts.params.num_entries = nentries;
96 options.clopts.instance = alloc(options.clopts.nclusters);
97 options.clopts.thrd_cnt = alloc(options.clopts.nclusters);
98 options.clopts.cltr_cnt = 0;
99 for(i; options.clopts.nclusters) {
100 options.clopts.thrd_cnt[i] = 0;
101 }
102
103
104 // if( fixedfd ) {
105 // options.file_cache.fixed_fds = true;
106 // }
107
108 // if( sqkpoll ) {
109 // options.file_cache.fixed_fds = true;
110 // }
111
112 // if( iokpoll ) {
113 // options.file_cache.open_flags |= O_DIRECT;
114 // }
115
116 if( left[0] == 0p ) { return; }
117
118 const char * path = left[0];
119 left++;
120
121 if( left[0] != 0p ) {
122 serr | "Too many trailing arguments!" | '\'' | path | '\'';
123 while(left[0] != 0p) {
124 serr | " - " | left[0];
125 left++;
126 }
127 exit(EXIT_FAILURE);
128 }
129
130 options.file_cache.path = path;
131}
Note: See TracBrowser for help on using the repository browser.