Ignore:
Timestamp:
Mar 21, 2022, 1:43:58 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
d672350
Parents:
3a40df6
Message:

Added statistics about sendfile in the webserver

File:
1 edited

Legend:

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

    r3a40df6 ref3c383  
    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) {
     
    266266}
    267267
    268 static inline int wait_and_process(header_g & this) {
     268static inline int wait_and_process(header_g & this, sendfile_stats_t & stats) {
    269269        wait(this.f);
    270270
     
    295295        }
    296296
     297        stats.header++;
     298
    297299        // It must be a Short read
    298300        this.len  -= this.f.result;
     
    306308        io_future_t f;
    307309        int fd; int pipe; size_t len; off_t off;
     310        short zipf_idx;
    308311        FSM_Result res;
    309312};
     
    314317        this.len = len;
    315318        this.off = 0;
     319        this.zipf_idx = -1;
     320        STATS: for(i; zipf_cnts) {
     321                if(len <= zipf_sizes[i]) {
     322                        this.zipf_idx = i;
     323                        break STATS;
     324                }
     325        }
     326        if(this.zipf_idx < 0) mutex(serr) serr | "SPLICE IN" | len | " greated than biggest zipf file";
    316327}
    317328
     
    329340}
    330341
    331 static inline int wait_and_process(splice_in_t & this) {
     342static inline int wait_and_process(splice_in_t & this, sendfile_stats_t & stats ) {
    332343        wait(this.f);
    333344
     
    345356                        return error(this.res, -ECONNRESET);
    346357                }
     358                mutex(serr) serr | "SPLICE IN got" | error | ", WTF!";
     359                return error(this.res, -ECONNRESET);
    347360        }
    348361
     
    357370                return done(this.res);
    358371        }
     372
     373        stats.splcin++;
     374        stats.avgrd[this.zipf_idx].calls++;
     375        stats.avgrd[this.zipf_idx].bytes += this.f.result;
    359376
    360377        // It must be a Short read
     
    398415}
    399416
    400 static inline void wait_and_process(splice_out_g & this) {
     417static inline void wait_and_process(splice_out_g & this, sendfile_stats_t & stats ) {
    401418        wait(this.f);
    402419
     
    414431                        return error(this, -ECONNRESET);
    415432                }
     433                mutex(serr) serr | "SPLICE OUT got" | error | ", WTF!";
     434                return error(this, -ECONNRESET);
    416435        }
    417436
     
    428447
    429448SHORT_WRITE:
     449        stats.splcot++;
     450
    430451        // It must be a Short Write
    431452        this.len -= this.f.result;
     
    434455}
    435456
    436 int answer_sendfile( int pipe[2], int fd, int ans_fd, size_t fsize ) {
     457int answer_sendfile( int pipe[2], int fd, int ans_fd, size_t fsize, sendfile_stats_t & stats ) {
     458        stats.calls++;
    437459        #if defined(LINKED_IO)
    438460                char buffer[512];
     
    443465
    444466                RETRY_LOOP: for() {
     467                        stats.tries++;
    445468                        int have = need(header.res) + need(splice_in.res) + 1;
    446469                        int idx = 0;
     
    461484                        // we may need to kill the connection if it fails
    462485                        // If it already completed, this is a no-op
    463                         wait_and_process(splice_in);
     486                        wait_and_process(splice_in, stats);
    464487
    465488                        if(is_error(splice_in.res)) {
     
    469492
    470493                        // Process the other 2
    471                         wait_and_process(header);
    472                         wait_and_process(splice_out);
     494                        wait_and_process(header, stats);
     495                        wait_and_process(splice_out, stats);
    473496
    474497                        if(is_done(splice_out.res)) {
     
    490513                return len + fsize;
    491514        #else
     515                stats.tries++;
    492516                int ret = answer_header(fd, fsize);
    493517                if( ret < 0 ) { close(fd); return ret; }
Note: See TracChangeset for help on using the changeset viewer.