Changeset d9c2284


Ignore:
Timestamp:
Jul 20, 2020, 4:32:04 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
5751a56
Parents:
124c1b7
Message:

Started doing preliminary work to use Fixed FDs. Starting with the thread pipes.

Location:
benchmark/io/http
Files:
4 edited

Legend:

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

    r124c1b7 rd9c2284  
    192192}
    193193
     194[int *, int] filefds(int extra) {
     195        if(!file_cache.entries) {
     196                abort("File cache not filled!\n");
     197        }
     198
     199        return [aalloc(extra), 0];
     200}
     201
     202
    194203void close_cache() {
    195204        for(idx; file_cache.size) {
  • benchmark/io/http/filecache.hfa

    r124c1b7 rd9c2284  
    1111[int fd, size_t size] get_file( * const char file, size_t len );
    1212void fill_cache( const char * path );
     13[int *, int] filefds( int extra );
    1314void close_cache();
  • benchmark/io/http/main.cfa

    r124c1b7 rd9c2284  
    9393                &wait_connect = &chan;
    9494
     95                int pipe_cnt = options.clopts.nworkers * 2;
     96                int pipe_off;
     97                int * fds;
     98                [fds, pipe_off] = filefds( pipe_cnt );
     99                for(i; 0 ~ pipe_cnt ~ 2) {
     100                        int ret = pipe(&fds[pipe_off + i]);
     101                        if( ret < 0 ) { abort( "pipe error: (%d) %s\n", (int)errno, strerror(errno) ); }
     102                }
     103
    95104                {
    96105                        ServerProc procs[options.clopts.nprocs];
    97106                        {
    98107                                Worker workers[options.clopts.nworkers];
     108                                for(i; options.clopts.nworkers) {
     109                                        if( options.file_cache.fixed_fds ) {
     110                                                workers[i].pipe[0] = pipe_off + (i * 2) + 0;
     111                                                workers[i].pipe[1] = pipe_off + (i * 2) + 1;
     112                                        }
     113                                        else {
     114                                                workers[i].pipe[0] = fds[pipe_off + (i * 2) + 0];
     115                                                workers[i].pipe[1] = fds[pipe_off + (i * 2) + 1];
     116                                        }
     117                                        unpark( workers[i] __cfaabi_dbg_ctx2 );
     118                                }
    99119                                printf("%d workers started on %d processors\n", options.clopts.nworkers, options.clopts.nprocs);
    100120                                {
     
    117137                        printf("Workers Closed\n");
    118138                }
     139
     140                for(i; pipe_cnt) {
     141                        ret = close( fds[pipe_off + i] );
     142                        if(ret < 0) {
     143                                abort( "close pipe error: (%d) %s\n", (int)errno, strerror(errno) );
     144                        }
     145                }
     146                free(fds);
    119147        }
    120148
  • benchmark/io/http/worker.cfa

    r124c1b7 rd9c2284  
    1212#include "filecache.hfa"
    1313
    14 extern "C" {
    15 // extern ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
    16 extern ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags);
    17 }
    18 
    19 ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count) {
    20         return splice(in_fd, offset, out_fd, 0p, count, 0);
    21 }
    22 
    23 
    2414//=============================================================================================
    2515// Worker Thread
     
    2717void ?{}( Worker & this ) {
    2818        ((thread&)this){ "Server Worker Thread", *options.clopts.instance };
    29         int ret = pipe(this.pipe);
    30         if( ret < 0 ) { abort( "pipe error: (%d) %s\n", (int)errno, strerror(errno) ); }
     19        this.pipe[0] = -1;
     20        this.pipe[1] = -1;
    3121}
    3222
    3323void main( Worker & this ) {
     24        park( __cfaabi_dbg_ctx );
     25        /* paranoid */ assert( this.pipe[0] != -1 );
     26        /* paranoid */ assert( this.pipe[1] != -1 );
     27
    3428        CONNECTION:
    3529        for() {
Note: See TracChangeset for help on using the changeset viewer.