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

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

Fixed some compilation errors.
Fixed file descriptor support in progress.

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