Changeset 92538ab for benchmark


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

Location:
benchmark
Files:
2 added
7 edited

Legend:

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

    r4559b34 r92538ab  
    3333//============================================================================================='
    3434
    35 thread StatsPrinter {};
     35thread StatsPrinter {
     36        Worker * workers;
     37        int worker_cnt;
     38};
    3639
    3740void ?{}( StatsPrinter & this, cluster & cl ) {
    3841        ((thread&)this){ "Stats Printer Thread", cl };
     42        this.worker_cnt = 0;
    3943}
    4044
    4145void ^?{}( StatsPrinter & mutex this ) {}
     46
     47#define eng3(X) (ws(3, 3, unit(eng( X ))))
    4248
    4349void main(StatsPrinter & this) {
     
    5157
    5258                print_stats_now( *active_cluster(), CFA_STATS_READY_Q | CFA_STATS_IO );
     59                if(this.worker_cnt != 0) {
     60                        uint64_t tries = 0;
     61                        uint64_t calls = 0;
     62                        uint64_t header = 0;
     63                        uint64_t splcin = 0;
     64                        uint64_t splcot = 0;
     65                        struct {
     66                                volatile uint64_t calls;
     67                                volatile uint64_t bytes;
     68                        } avgrd[zipf_cnts];
     69                        memset(avgrd, 0, sizeof(avgrd));
     70
     71                        for(i; this.worker_cnt) {
     72                                tries += this.workers[i].stats.sendfile.tries;
     73                                calls += this.workers[i].stats.sendfile.calls;
     74                                header += this.workers[i].stats.sendfile.header;
     75                                splcin += this.workers[i].stats.sendfile.splcin;
     76                                splcot += this.workers[i].stats.sendfile.splcot;
     77                                for(j; zipf_cnts) {
     78                                        avgrd[j].calls += this.workers[i].stats.sendfile.avgrd[j].calls;
     79                                        avgrd[j].bytes += this.workers[i].stats.sendfile.avgrd[j].bytes;
     80                                }
     81                        }
     82
     83                        double ratio = ((double)tries) / calls;
     84
     85                        sout | "----- Worker Stats -----";
     86                        sout | "sendfile  : " | calls | "calls," | tries | "tries (" | ratio | " try/call)";
     87                        sout | "            " | header | "header," | splcin | "splice in," | splcot | "splice out";
     88                        sout | " - zipf sizes:";
     89                        for(i; zipf_cnts) {
     90                                double written = avgrd[i].calls > 0 ? ((double)avgrd[i].bytes) / avgrd[i].calls : 0;
     91                                sout | "        " | zipf_sizes[i] | "bytes," | avgrd[i].calls | "shorts," | written | "written";
     92                        }
     93                }
     94                else {
     95                        sout | "No Workers!";
     96                }
    5397        }
    5498}
     
    218262                        {
    219263                                Worker * workers = anew(options.clopts.nworkers);
     264                                cl[0].prnt->workers = workers;
     265                                cl[0].prnt->worker_cnt = options.clopts.nworkers;
    220266                                for(i; options.clopts.nworkers) {
    221267                                        // if( options.file_cache.fixed_fds ) {
     
    311357        }
    312358}
     359
     360const size_t zipf_sizes[] = { 102, 204, 307, 409, 512, 614, 716, 819, 921, 1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192, 9216, 10240, 20480, 30720, 40960, 51200, 61440, 71680, 81920, 92160, 102400, 204800, 307200, 409600, 512000, 614400, 716800, 819200, 921600 };
     361static_assert(zipf_cnts == sizeof(zipf_sizes) / sizeof(zipf_sizes[0]));
  • benchmark/io/http/parhttperf

    r4559b34 r92538ab  
    66
    77mkdir -p out
    8 rm -v out/*
     8rm out/*
     9echo "httperf --client [0-$(($NTHREADS - 1))]/$NTHREADS $@ > out/result.[0-$(($NTHREADS - 1))].out"
    910for ((i=0; i<$NTHREADS; i++))
    1011do
    11         # echo "httperf --client $i/$NTHREADS $@ > out/result.$i.out"
    1212        httperf --client $i/$NTHREADS $@ > out/result.$i.out &
    1313done
  • 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; }
  • benchmark/io/http/protocol.hfa

    r4559b34 r92538ab  
    11#pragma once
     2
     3struct sendfile_stats_t;
    24
    35enum HttpCode {
     
    1820int answer_plaintext( int fd );
    1921int answer_empty( int fd );
    20 int answer_sendfile( int pipe[2], int fd, int ans_fd, size_t count );
     22int answer_sendfile( int pipe[2], int fd, int ans_fd, size_t count, struct sendfile_stats_t & );
    2123
    2224[HttpCode code, bool closed, * const char file, size_t len] http_read(int fd, []char buffer, size_t len);
  • benchmark/io/http/worker.cfa

    r4559b34 r92538ab  
    2323        this.pipe[1] = -1;
    2424        this.done = false;
     25
     26        this.stats.sendfile.calls = 0;
     27        this.stats.sendfile.tries = 0;
     28        this.stats.sendfile.header = 0;
     29        this.stats.sendfile.splcin = 0;
     30        this.stats.sendfile.splcot = 0;
     31        for(i; zipf_cnts) {
     32                this.stats.sendfile.avgrd[i].calls = 0;
     33                this.stats.sendfile.avgrd[i].bytes = 0;
     34        }
    2535}
    2636
     
    123133
    124134                        // Send the desired file
    125                         int ret = answer_sendfile( this.pipe, fd, ans_fd, count);
     135                        int ret = answer_sendfile( this.pipe, fd, ans_fd, count, this.stats.sendfile );
    126136                        if( ret == -ECONNRESET ) break REQUEST;
    127137
  • benchmark/io/http/worker.hfa

    r4559b34 r92538ab  
    1111//=============================================================================================
    1212
     13extern const size_t zipf_sizes[];
     14enum { zipf_cnts = 36, };
     15
     16struct sendfile_stats_t {
     17        volatile uint64_t calls;
     18        volatile uint64_t tries;
     19        volatile uint64_t header;
     20        volatile uint64_t splcin;
     21        volatile uint64_t splcot;
     22        struct {
     23                volatile uint64_t calls;
     24                volatile uint64_t bytes;
     25        } avgrd[zipf_cnts];
     26};
     27
    1328thread Worker {
    1429        int pipe[2];
     
    1833        int flags;
    1934        volatile bool done;
     35        struct {
     36                sendfile_stats_t sendfile;
     37        } stats;
    2038};
    2139void ?{}( Worker & this);
  • benchmark/plot.py

    r4559b34 r92538ab  
    4040}
    4141
    42 def plot(data, x, y):
     42def plot(data, x, y, out):
    4343        fig, ax = plt.subplots()
    4444        colors = itertools.cycle(['#0095e3','#006cb4','#69df00','#0aa000','#fb0300','#e30002','#fd8f00','#ff7f00','#8f00d6','#4b009a','#ffff00','#b13f00'])
     
    6767        ax.yaxis.set_major_formatter( EngFormatter(unit=field_names[y].unit) )
    6868        plt.legend(loc='upper left')
    69         plt.show()
     69        if out:
     70                plt.savefig(out)
     71        else:
     72                plt.show()
    7073
    7174
     
    7578        parser = parser = argparse.ArgumentParser(description='Python Script to draw R.M.I.T. results')
    7679        parser.add_argument('-f', '--file', nargs='?', type=argparse.FileType('r'), default=sys.stdin)
     80        parser.add_argument('-o', '--out', nargs='?', type=str, default=None)
     81        parser.add_argument('-y', nargs='?', type=str, default="")
    7782
    7883        try:
     
    103108                        fields.add(label)
    104109
    105         print(series)
    106         print("fields")
    107         for f in fields:
    108                 print("{}".format(f))
     110        if not options.out :
     111                print(series)
     112                print("fields")
     113                for f in fields:
     114                        print("{}".format(f))
    109115
    110         plot(data, "Number of processors", "ns per ops")
     116        if options.y and options.y in field_names.keys():
     117                plot(data, "Number of processors", options.y, options.out)
     118        else:
     119                if options.y:
     120                        print("Could not find key '{}', defaulting to 'ns per ops'".format(options.y))
     121                plot(data, "Number of processors", "ns per ops", options.out)
Note: See TracChangeset for help on using the changeset viewer.