Changeset 348f81d


Ignore:
Timestamp:
Feb 23, 2021, 4:02:27 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:
b664af2
Parents:
a06023f
Message:

Added option to isolate processor so everything has it's own cluster

Location:
benchmark/io/http
Files:
5 edited

Legend:

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

    ra06023f r348f81d  
    2929
    3030//=============================================================================================
    31 // Globals
    32 //=============================================================================================
    33 struct ServerProc {
    34         processor self;
    35 };
    36 
    37 void ?{}( ServerProc & this ) {
    38         /* paranoid */ assert( options.clopts.instance != 0p );
    39         (this.self){ "Benchmark Processor", *options.clopts.instance };
    40 
    41         #if !defined(__CFA_NO_STATISTICS__)
    42                 if( options.clopts.procstats ) {
    43                         print_stats_at_exit( this.self, options.clopts.instance->print_stats );
    44                 }
    45                 if( options.clopts.viewhalts ) {
    46                         print_halts( this.self );
    47                 }
    48         #endif
    49 }
    50 
    51 struct ServerIoContext {
    52         io_context self;
    53 };
    54 
    55 void ?{}( ServerIoContext & this ) {
    56         /* paranoid */ assert( options.clopts.instance != 0p );
    57         (this.self){ *options.clopts.instance };
    58 }
    59 
    60 extern void init_protocol(void);
    61 extern void deinit_protocol(void);
    62 
    63 //=============================================================================================
    6431// Stats Printer
    6532//============================================================================================='
     
    6734thread StatsPrinter {};
    6835
    69 void ?{}( StatsPrinter & this ) {
    70         ((thread&)this){ "Stats Printer Thread" };
     36void ?{}( StatsPrinter & this, cluster & cl ) {
     37        ((thread&)this){ "Stats Printer Thread", cl };
    7138}
    7239
     
    8047                sleep(10`s);
    8148
    82                 print_stats_now( *options.clopts.instance, CFA_STATS_READY_Q | CFA_STATS_IO );
    83         }
    84 }
     49                print_stats_now( *active_cluster(), CFA_STATS_READY_Q | CFA_STATS_IO );
     50        }
     51}
     52
     53//=============================================================================================
     54// Globals
     55//=============================================================================================
     56// struct ServerProc {
     57//      processor self;
     58// };
     59
     60// void ?{}( ServerProc & this ) {
     61//      /* paranoid */ assert( options.clopts.instance != 0p );
     62//      (this.self){ "Benchmark Processor", *options.clopts.instance };
     63
     64//      #if !defined(__CFA_NO_STATISTICS__)
     65//              if( options.clopts.procstats ) {
     66//                      print_stats_at_exit( this.self, options.clopts.instance->print_stats );
     67//              }
     68//              if( options.clopts.viewhalts ) {
     69//                      print_halts( this.self );
     70//              }
     71//      #endif
     72// }
     73
     74// struct ServerIoContext {
     75//      io_context self;
     76// };
     77
     78// void ?{}( ServerIoContext & this ) {
     79//      /* paranoid */ assert( options.clopts.instance != 0p );
     80//      (this.self){ *options.clopts.instance };
     81// }
     82
     83struct ServerCluster {
     84        cluster self;
     85        processor    * procs;
     86        io_context   * ctxs;
     87        StatsPrinter * prnt;
     88
     89};
     90
     91void ?{}( ServerCluster & this ) {
     92        (this.self){ "Server Cluster", options.clopts.params };
     93
     94        this.procs = alloc(options.clopts.nprocs);
     95        for(i; options.clopts.nprocs) {
     96                (this.procs[i]){ "Benchmark Processor", this.self };
     97
     98                #if !defined(__CFA_NO_STATISTICS__)
     99                        if( options.clopts.procstats ) {
     100                                print_stats_at_exit( *this.procs, this.self.print_stats );
     101                        }
     102                        if( options.clopts.viewhalts ) {
     103                                print_halts( *this.procs );
     104                        }
     105                #endif
     106        }
     107
     108        this.ctxs = alloc(options.clopts.nprocs);
     109        for(i; options.clopts.nprocs) {
     110                (this.ctxs[i]){ this.self };
     111        }
     112
     113        this.prnt = alloc(options.clopts.nprocs);
     114        for(i; options.clopts.nprocs) {
     115                (this.prnt[i]){ this.self };
     116        }
     117
     118        #if !defined(__CFA_NO_STATISTICS__)
     119                print_stats_at_exit( this.self, CFA_STATS_READY_Q | CFA_STATS_IO );
     120        #endif
     121
     122        options.clopts.instance[options.clopts.cltr_cnt] = &this.self;
     123        options.clopts.cltr_cnt++;
     124}
     125
     126void ^?{}( ServerCluster & this ) {
     127        for(i; options.clopts.nprocs) {
     128                ^(this.prnt[i]){};
     129        }
     130        free(this.prnt);
     131
     132        for(i; options.clopts.nprocs) {
     133                ^(this.ctxs[i]){};
     134        }
     135        free(this.ctxs);
     136
     137        for(i; options.clopts.nprocs) {
     138                ^(this.procs[i]){};
     139        }
     140        free(this.procs);
     141
     142        ^(this.self){};
     143}
     144
     145extern void init_protocol(void);
     146extern void deinit_protocol(void);
    85147
    86148//=============================================================================================
     
    146208        // Run Server Cluster
    147209        {
    148                 cluster cl = { "Server Cluster", options.clopts.params };
    149                 #if !defined(__CFA_NO_STATISTICS__)
    150                         print_stats_at_exit( cl, CFA_STATS_READY_Q | CFA_STATS_IO );
    151                 #endif
    152                 options.clopts.instance = &cl;
    153 
    154 
    155210                int pipe_cnt = options.clopts.nworkers * 2;
    156211                int pipe_off;
     
    167222
    168223                {
    169                         ServerProc procs[options.clopts.nprocs];
    170                         ServerIoContext ioctxs[options.clopts.nprocs];
    171                         // StatsPrinter printer;
     224                        ServerCluster cl[options.clopts.nclusters];
    172225
    173226                        init_protocol();
     
    190243                                        unpark( workers[i] );
    191244                                }
    192                                 sout | options.clopts.nworkers | "workers started on" | options.clopts.nprocs | "processors";
     245                                sout | options.clopts.nworkers | "workers started on" | options.clopts.nprocs | "processors /" | options.clopts.nclusters | "clusters";
     246                                for(i; options.clopts.nclusters) {
     247                                        sout | options.clopts.thrd_cnt[i] | nonl;
     248                                }
     249                                sout | nl;
    193250                                {
    194251                                        char buffer[128];
     
    230287                        sout | "done";
    231288
    232                         sout | "Stopping processors..." | nonl; flush( sout );
     289                        sout | "Stopping processors/clusters..." | nonl; flush( sout );
    233290                }
    234291                sout | "done";
  • benchmark/io/http/options.cfa

    ra06023f r348f81d  
    1313#include <kernel.hfa>
    1414#include <parseargs.hfa>
     15#include <stdlib.hfa>
    1516
    1617#include <stdlib.h>
     
    3637
    3738        { // cluster
     39                1,     // nclusters;
    3840                1,     // nprocs;
    3941                1,     // nworkers;
     
    5052        // bool iokpoll = false;
    5153        unsigned nentries = 16;
     54        bool isolate = false;
    5255
    5356
     
    5659                { 'c', "cpus",           "Number of processors to use", options.clopts.nprocs},
    5760                { 't', "threads",        "Number of worker threads to use", options.clopts.nworkers},
     61                {'\0', "isolate",        "Create one cluster per processor", isolate, parse_settrue},
    5862                {'\0', "log",            "Enable logs", options.log, parse_settrue},
    5963                {'\0', "accept-backlog", "Maximum number of pending accepts", options.socket.backlog},
     
    8589                nentries = v;
    8690        }
     91        if(isolate) {
     92                options.clopts.nclusters = options.clopts.nprocs;
     93                options.clopts.nprocs = 1;
     94        }
    8795        options.clopts.params.num_entries = nentries;
     96        options.clopts.instance = alloc(options.clopts.nclusters);
     97        options.clopts.thrd_cnt = alloc(options.clopts.nclusters);
     98        options.clopts.cltr_cnt = 0;
     99        for(i; options.clopts.nclusters) {
     100                options.clopts.thrd_cnt[i] = 0;
     101        }
     102
    88103
    89104        // if( fixedfd ) {
  • benchmark/io/http/options.hfa

    ra06023f r348f81d  
    2626
    2727        struct {
     28                int nclusters;
    2829                int nprocs;
    2930                int nworkers;
     
    3132                bool procstats;
    3233                bool viewhalts;
    33                 cluster * instance;
     34                cluster ** instance;
     35                size_t   * thrd_cnt;
     36                size_t     cltr_cnt;
    3437        } clopts;
    3538};
  • benchmark/io/http/protocol.cfa

    ra06023f r348f81d  
    182182
    183183void ?{}( DateFormater & this ) {
    184         ((thread&)this){ "Server Date Thread", *options.clopts.instance };
     184        ((thread&)this){ "Server Date Thread", *options.clopts.instance[0] };
    185185        this.idx = 0;
    186186        memset( this.buffers[0].buff, 0, sizeof(this.buffers[0]) );
  • benchmark/io/http/worker.cfa

    ra06023f r348f81d  
    1717//=============================================================================================
    1818void ?{}( Worker & this ) {
    19         ((thread&)this){ "Server Worker Thread", *options.clopts.instance };
     19        size_t cli = rand() % options.clopts.cltr_cnt;
     20        ((thread&)this){ "Server Worker Thread", *options.clopts.instance[cli] };
     21        options.clopts.thrd_cnt[cli]++;
    2022        this.pipe[0] = -1;
    2123        this.pipe[1] = -1;
Note: See TracChangeset for help on using the changeset viewer.