source: benchmark/io/http/options.cfa @ 5ad381b

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

Started to work on httpforall also supporting techempower 'plaintext' benchmark.

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