source: benchmark/io/http/options.cfa@ dd92fe9

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 dd92fe9 was 56c44dc, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Worker now each do their own accept4

  • Property mode set to 100644
File size: 2.9 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 <kernel.hfa>
12#include <parseargs.hfa>
13
14Options options @= {
15 { // file_cache
16 0, // open_flags;
17 42u, // hash_seed;
18 0, // size;
19 false, // list;
20 false // fixed_fds
21 },
22
23 { // socket
24 8080, // port
25 10, // backlog
26 1024 // buflen
27 },
28
29 { // cluster
30 1, // nprocs;
31 1, // nworkers;
32 0, // flags;
33 false, // procstats
34 false, // viewhalts
35 0, // instance;
36 }
37};
38
39const char * parse_options( int argc, char * argv[] ) {
40 bool subthrd = false;
41 bool eagrsub = false;
42 bool fixedfd = false;
43 bool sqkpoll = false;
44 bool iokpoll = false;
45 unsigned sublen = 16;
46
47 static cfa_option opt[] = {
48 {'p', "port", "Port the server will listen on", options.socket.port},
49 {'c', "cpus", "Number of processors to use", options.clopts.nprocs},
50 {'t', "threads", "Number of worker threads to use", options.clopts.nworkers},
51 {'b', "accept-backlog", "Maximum number of pending accepts", options.socket.backlog},
52 {'r', "request_len", "Maximum number of bytes in the http request, requests with more data will be answered with Http Code 414", options.socket.buflen},
53 {'S', "seed", "seed to use for hashing", options.file_cache.hash_seed },
54 {'C', "cache-size", "Size of the cache to use, if set to small, will uses closes power of 2", options.file_cache.size },
55 {'l', "list-files", "List the files in the specified path and exit", options.file_cache.list, parse_settrue },
56 {'s', "submitthread", "If set, cluster uses polling thread to submit I/O", subthrd, parse_settrue },
57 {'e', "eagersubmit", "If set, cluster submits I/O eagerly but still aggregates submits", eagrsub, parse_settrue},
58 {'f', "fixed-fds", "If set, files are open eagerly and pre-registered with the cluster", fixedfd, parse_settrue},
59 {'k', "kpollsubmit", "If set, cluster uses IORING_SETUP_SQPOLL, implies -f", sqkpoll, parse_settrue },
60 {'i', "kpollcomplete", "If set, cluster uses IORING_SETUP_IOPOLL", iokpoll, parse_settrue },
61 {'L', "submitlength", "Max number of submitions that can be submitted together", sublen },
62
63 };
64 int opt_cnt = sizeof(opt) / sizeof(cfa_option);
65
66 char **left;
67 parse_args( argc, argv, opt, opt_cnt, "[OPTIONS]... [PATH]\ncforall http server", left );
68
69 options.clopts.params.poller_submits = subthrd;
70 options.clopts.params.eager_submits = eagrsub;
71
72 if( fixedfd ) {
73 options.file_cache.fixed_fds = true;
74 }
75
76 if( sqkpoll ) {
77 options.clopts.params.poll_submit = true;
78 options.file_cache.fixed_fds = true;
79 }
80
81 if( iokpoll ) {
82 options.clopts.params.poll_complete = true;
83 options.file_cache.open_flags |= O_DIRECT;
84 }
85
86 options.clopts.params.num_ready = sublen;
87
88 if( left[0] == 0p ) { return "."; }
89
90 const char * path = left[0];
91 left++;
92
93 if( left[0] != 0p ) {
94 abort("Too many trailing arguments!\n");
95 }
96
97 return path;
98}
Note: See TracBrowser for help on using the repository browser.