Ignore:
Timestamp:
Apr 10, 2022, 2:53:18 PM (4 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
d8e2a09
Parents:
4559b34 (diff), 6256891 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Resolve conflict

File:
1 edited

Legend:

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

    r4559b34 r92538ab  
    2424
    2525#include "options.hfa"
     26#include "worker.hfa"
    2627
    2728#define PLAINTEXT_1WRITE
     
    156157
    157158                count -= ret;
    158                 offset += ret;
    159159                size_t in_pipe = ret;
    160160                SPLICE2: while(in_pipe > 0) {
     
    173173}
    174174
    175 static void zero_sqe(struct io_uring_sqe * sqe) {
    176         sqe->flags = 0;
    177         sqe->ioprio = 0;
    178         sqe->fd = 0;
    179         sqe->off = 0;
    180         sqe->addr = 0;
    181         sqe->len = 0;
    182         sqe->fsync_flags = 0;
    183         sqe->__pad2[0] = 0;
    184         sqe->__pad2[1] = 0;
    185         sqe->__pad2[2] = 0;
    186         sqe->fd = 0;
    187         sqe->off = 0;
    188         sqe->addr = 0;
    189         sqe->len = 0;
    190 }
    191 
    192175enum FSM_STATE {
    193176        Initial,
     
    266249}
    267250
    268 static inline int wait_and_process(header_g & this) {
     251static inline int wait_and_process(header_g & this, sendfile_stats_t & stats) {
    269252        wait(this.f);
    270253
     
    295278        }
    296279
     280        stats.header++;
     281
    297282        // It must be a Short read
    298283        this.len  -= this.f.result;
     
    306291        io_future_t f;
    307292        int fd; int pipe; size_t len; off_t off;
     293        short zipf_idx;
    308294        FSM_Result res;
    309295};
     
    314300        this.len = len;
    315301        this.off = 0;
     302        this.zipf_idx = -1;
     303        STATS: for(i; zipf_cnts) {
     304                if(len <= zipf_sizes[i]) {
     305                        this.zipf_idx = i;
     306                        break STATS;
     307                }
     308        }
     309        if(this.zipf_idx < 0) mutex(serr) serr | "SPLICE IN" | len | " greated than biggest zipf file";
    316310}
    317311
     
    329323}
    330324
    331 static inline int wait_and_process(splice_in_t & this) {
     325static inline int wait_and_process(splice_in_t & this, sendfile_stats_t & stats ) {
    332326        wait(this.f);
    333327
     
    345339                        return error(this.res, -ECONNRESET);
    346340                }
     341                mutex(serr) serr | "SPLICE IN got" | error | ", WTF!";
     342                return error(this.res, -ECONNRESET);
    347343        }
    348344
     
    357353                return done(this.res);
    358354        }
     355
     356        stats.splcin++;
     357        stats.avgrd[this.zipf_idx].calls++;
     358        stats.avgrd[this.zipf_idx].bytes += this.f.result;
    359359
    360360        // It must be a Short read
     
    398398}
    399399
    400 static inline void wait_and_process(splice_out_g & this) {
     400static inline void wait_and_process(splice_out_g & this, sendfile_stats_t & stats ) {
    401401        wait(this.f);
    402402
     
    414414                        return error(this, -ECONNRESET);
    415415                }
     416                mutex(serr) serr | "SPLICE OUT got" | error | ", WTF!";
     417                return error(this, -ECONNRESET);
    416418        }
    417419
     
    428430
    429431SHORT_WRITE:
     432        stats.splcot++;
     433
    430434        // It must be a Short Write
    431435        this.len -= this.f.result;
     
    434438}
    435439
    436 int answer_sendfile( int pipe[2], int fd, int ans_fd, size_t fsize ) {
     440int answer_sendfile( int pipe[2], int fd, int ans_fd, size_t fsize, sendfile_stats_t & stats ) {
     441        stats.calls++;
    437442        #if defined(LINKED_IO)
    438443                char buffer[512];
     
    443448
    444449                RETRY_LOOP: for() {
     450                        stats.tries++;
    445451                        int have = need(header.res) + need(splice_in.res) + 1;
    446452                        int idx = 0;
     
    461467                        // we may need to kill the connection if it fails
    462468                        // If it already completed, this is a no-op
    463                         wait_and_process(splice_in);
     469                        wait_and_process(splice_in, stats);
    464470
    465471                        if(is_error(splice_in.res)) {
     
    469475
    470476                        // Process the other 2
    471                         wait_and_process(header);
    472                         wait_and_process(splice_out);
     477                        wait_and_process(header, stats);
     478                        wait_and_process(splice_out, stats);
    473479
    474480                        if(is_done(splice_out.res)) {
     
    490496                return len + fsize;
    491497        #else
     498                stats.tries++;
    492499                int ret = answer_header(fd, fsize);
    493500                if( ret < 0 ) { close(fd); return ret; }
Note: See TracChangeset for help on using the changeset viewer.