Changeset b57db73 for benchmark/io/http


Ignore:
Timestamp:
Jan 16, 2021, 5:20:59 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
0197418
Parents:
35ea4f3
Message:

httpforall now only loads file if explicit path is given.

Location:
benchmark/io/http
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/http/filecache.cfa

    r35ea4f3 rb57db73  
    209209
    210210[int *, int] filefds(int extra) {
     211        if(!options.file_cache.path) {
     212                int * data = alloc(extra);
     213                return [data, 0];
     214        }
     215
    211216        if(!file_cache.entries) {
    212217                abort("File cache not filled!\n");
  • benchmark/io/http/main.cfa

    r35ea4f3 rb57db73  
    8080        //===================
    8181        // Parse args
    82         const char * path = parse_options(argc, argv);
     82        parse_options(argc, argv);
    8383
    8484        //===================
    8585        // Open Files
    86         sout | "Filling cache from" | path;
    87         fill_cache( path );
     86        if( options.file_cache.path ) {
     87                sout | "Filling cache from" | options.file_cache.path;
     88                fill_cache( options.file_cache.path );
     89        }
    8890
    8991        //===================
     
    147149                }
    148150
    149                 if(options.file_cache.fixed_fds) {
     151                if(options.file_cache.path && options.file_cache.fixed_fds) {
    150152                        register_fixed_files(cl, fds, pipe_off);
    151153                }
     
    184186                                }
    185187
    186                                 sout | "Notifying connections";
     188                                sout | "Notifying connections..." | nonl; flush( sout );
    187189                                for(i; options.clopts.nworkers) {
    188190                                        workers[i].done = true;
    189191                                        cancel(workers[i].cancel);
    190192                                }
    191 
    192                                 sout | "Shutting down socket";
     193                                sout | "done";
     194
     195                                sout | "Shutting down socket..." | nonl; flush( sout );
    193196                                int ret = shutdown( server_fd, SHUT_RD );
    194                                 if( ret < 0 ) { abort( "shutdown error: (%d) %s\n", (int)errno, strerror(errno) ); }
     197                                if( ret < 0 ) {
     198                                        abort( "shutdown error: (%d) %s\n", (int)errno, strerror(errno) );
     199                                }
     200                                sout | "done";
    195201
    196202                                //===================
    197203                                // Close Socket
    198                                 sout | "Closing Socket";
     204                                sout | "Closing Socket..." | nonl; flush( sout );
    199205                                ret = close( server_fd );
    200206                                if(ret < 0) {
    201207                                        abort( "close socket error: (%d) %s\n", (int)errno, strerror(errno) );
    202208                                }
    203                                 sout | "Stopping connection threads..." | nonl;
     209                                sout | "Stopping connection threads..." | nonl; flush( sout );
    204210                        }
    205211                        sout | "done";
    206212
    207                         sout | "Stopping protocol threads..." | nonl;
     213                        sout | "Stopping protocol threads..." | nonl; flush( sout );
    208214                        deinit_protocol();
    209215                        sout | "done";
    210216
    211                         sout | "Stopping processors..." | nonl;
     217                        sout | "Stopping processors..." | nonl; flush( sout );
    212218                }
    213219                sout | "done";
    214220
    215                 sout | "Closing splice fds..." | nonl;
     221                sout | "Closing splice fds..." | nonl; flush( sout );
    216222                for(i; pipe_cnt) {
    217223                        ret = close( fds[pipe_off + i] );
     
    223229                sout | "done";
    224230
    225                 sout | "Stopping processors..." | nonl;
     231                sout | "Stopping processors..." | nonl; flush( sout );
    226232        }
    227233        sout | "done";
     
    229235        //===================
    230236        // Close Files
    231         sout | "Closing open files..." | nonl;
    232         close_cache();
    233         sout | "done";
    234 }
     237        if( options.file_cache.path ) {
     238                sout | "Closing open files..." | nonl; flush( sout );
     239                close_cache();
     240                sout | "done";
     241        }
     242}
  • benchmark/io/http/options.cfa

    r35ea4f3 rb57db73  
    99}
    1010
     11#include <fstream.hfa>
    1112#include <kernel.hfa>
    1213#include <parseargs.hfa>
    1314
     15#include <stdlib.h>
    1416#include <string.h>
    1517
     
    1820
    1921        { // file_cache
     22                0,     // path
    2023                0,     // open_flags;
    2124                42u,   // hash_seed;
     
    3437                1,     // nprocs;
    3538                1,     // nworkers;
    36                 0,     // flags;
     39                {},     // params;
    3740                false, // procstats
    3841                false, // viewhalts
     
    4144};
    4245
    43 const char * parse_options( int argc, char * argv[] ) {
     46void parse_options( int argc, char * argv[] ) {
    4447        bool subthrd = false;
    4548        bool eagrsub = false;
     
    97100
    98101        if( left[0] != 0p ) {
    99                 abort("Too many trailing arguments!\n");
     102                serr | "Too many trailing arguments!";
     103                exit(EXIT_FAILURE);
    100104        }
    101105
    102         return path;
     106        options.file_cache.path = path;
    103107}
  • benchmark/io/http/options.hfa

    r35ea4f3 rb57db73  
    1111
    1212        struct {
     13                const char * path;
    1314                int open_flags;
    1415                uint32_t hash_seed;
     
    3637extern Options options;
    3738
    38 const char * parse_options( int argc, char * argv[] );
     39void parse_options( int argc, char * argv[] );
  • benchmark/io/http/protocol.cfa

    r35ea4f3 rb57db73  
    2626        "HTTP/1.1 400 Bad Request\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n",
    2727        "HTTP/1.1 404 Not Found\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n",
     28        "HTTP/1.1 405 Method Not Allowed\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n",
    2829        "HTTP/1.1 408 Request Timeout\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n",
    2930        "HTTP/1.1 413 Payload Too Large\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n",
     
    3738        400,
    3839        404,
     40        405,
    3941        408,
    4042        413,
  • benchmark/io/http/protocol.hfa

    r35ea4f3 rb57db73  
    77        E400,
    88        E404,
     9        E405,
    910        E408,
    1011        E413,
  • benchmark/io/http/worker.cfa

    r35ea4f3 rb57db73  
    9797                        }
    9898
     99                        if( !options.file_cache.path ) {
     100                                if( options.log ) {
     101                                        sout | "=== File Not Found (" | nonl;
     102                                        write(sout, file, name_size);
     103                                        sout | ") ===";
     104                                }
     105                                answer_error(fd, E405);
     106                                continue REQUEST;
     107                        }
     108
    99109                        // Get the fd from the file cache
    100110                        int ans_fd;
     
    104114                        // If we can't find the file, return 404
    105115                        if( ans_fd < 0 ) {
    106                                 sout | "=== File Not Found (" | nonl;
    107                                 write(sout, file, name_size);
    108                                 sout | ") ===";
     116                                if( options.log ) {
     117                                        sout | "=== File Not Found (" | nonl;
     118                                        write(sout, file, name_size);
     119                                        sout | ") ===";
     120                                }
    109121                                answer_error(fd, E404);
    110122                                continue REQUEST;
Note: See TracChangeset for help on using the changeset viewer.