source: benchmark/io/http/options.cfa @ 80d3b1b

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 80d3b1b was 481ee28, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Removed experiment type, server just supports both urls.
Logging is now optional.
Added done flag so spurious invalid accepts are caught.

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