Changeset c76bd34 for benchmark


Ignore:
Timestamp:
Oct 7, 2020, 4:31:43 PM (5 years ago)
Author:
Colby Alexander Parsons <caparsons@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
848439f
Parents:
ae2c27a (diff), 597c5d18 (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:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc into master

Location:
benchmark
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • benchmark/Makefile.am

    rae2c27a rc76bd34  
    113113creation_cfa_generator_DURATION = 1000000000
    114114creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}
    115 creation_cfa_thread_DURATION = 10000000
    116 creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}
    117115creation_DURATION = 10000000
    118116
     
    148146
    149147cleancsv:
    150         rm -f compile.csv basic.csv ctxswitch.csv mutex.csv scheduling.csv
     148        rm -f compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv
    151149
    152150jenkins$(EXEEXT): cleancsv
     
    159157        +make mutex.csv
    160158        -+make mutex.diff.csv
    161         +make scheduling.csv
    162         -+make scheduling.diff.csv
     159        +make schedint.csv
     160        -+make schedint.diff.csv
    163161@DOifskipcompile@
    164162        cat compile.csv
     
    169167        cat mutex.csv
    170168        -cat mutex.diff.csv
    171         cat scheduling.csv
    172         -cat scheduling.diff.csv
     169        cat schedint.csv
     170        -cat schedint.diff.csv
    173171
    174172compile.csv:
     
    200198        $(srcdir)/fixcsv.sh $@
    201199
    202 scheduling.csv:
     200schedint.csv:
    203201        echo "building $@"
    204202        echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@
     
    291289ctxswitch-python_coroutine$(EXEEXT):
    292290        $(BENCH_V_PY)echo "#!/bin/sh" > a.out
    293         echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out
     291        echo "python3 $(srcdir)/ctxswitch/python_cor.py \"$$""@\"" >> a.out
    294292        chmod a+x a.out
    295293
    296294ctxswitch-nodejs_coroutine$(EXEEXT):
    297295        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
    298         echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out
     296        echo "nodejs $(srcdir)/ctxswitch/node_cor.js \"$$""@\"" >> a.out
    299297        chmod a+x a.out
    300298
    301299ctxswitch-nodejs_await$(EXEEXT):
    302300        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
    303         echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out
     301        echo "nodejs $(srcdir)/ctxswitch/node_await.js \"$$""@\"" >> a.out
    304302        chmod a+x a.out
    305303
     
    313311        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java
    314312        echo "#!/bin/sh" > a.out
    315         echo "java JavaThread" >> a.out
     313        echo "java JavaThread \"$$""@\"" >> a.out
    316314        chmod a+x a.out
    317315
     
    355353        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java
    356354        echo "#!/bin/sh" > a.out
    357         echo "java JavaThread" >> a.out
     355        echo "java JavaThread \"$$""@\"" >> a.out
    358356        chmod a+x a.out
    359357
     
    387385        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    388386        echo "#!/bin/sh" > a.out
    389         echo "java JavaThread" >> a.out
     387        echo "java JavaThread \"$$""@\"" >> a.out
    390388        chmod a+x a.out
    391389
     
    454452creation-python_coroutine$(EXEEXT):
    455453        $(BENCH_V_PY)echo "#!/bin/sh" > a.out
    456         echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out
     454        echo "python3 $(srcdir)/creation/python_cor.py \"$$""@\"" >> a.out
    457455        chmod a+x a.out
    458456
    459457creation-nodejs_coroutine$(EXEEXT):
    460458        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
    461         echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out
     459        echo "nodejs $(srcdir)/creation/node_cor.js \"$$""@\"" >> a.out
    462460        chmod a+x a.out
    463461
     
    471469        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    472470        echo "#!/bin/sh" > a.out
    473         echo "java JavaThread" >> a.out
     471        echo "java JavaThread \"$$""@\"" >> a.out
    474472        chmod a+x a.out
    475473
     
    492490
    493491compile-array$(EXEEXT):
    494         $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
     492        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/array.cfa
    495493
    496494compile-attributes$(EXEEXT):
    497         $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     495        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/attributes.cfa
    498496
    499497compile-empty$(EXEEXT):
    500         $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
     498        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(srcdir)/compile/empty.cfa
    501499
    502500compile-expression$(EXEEXT):
    503         $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
     501        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/expression.cfa
    504502
    505503compile-io$(EXEEXT):
    506         $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
     504        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/io1.cfa
    507505
    508506compile-monitor$(EXEEXT):
    509         $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
     507        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
    510508
    511509compile-operators$(EXEEXT):
    512         $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
     510        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/operators.cfa
    513511
    514512compile-thread$(EXEEXT):
    515         $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
     513        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/concurrent/thread.cfa
    516514
    517515compile-typeof$(EXEEXT):
    518         $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     516        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/typeof.cfa
    519517
    520518## =========================================================================================================
  • benchmark/creation/JavaThread.java

    rae2c27a rc76bd34  
    11public class JavaThread {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        private static int nextRandom (int x) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("10000") ;
     28        static private long times = Long.parseLong("10000") ;
    2929
    3030        public static class MyThread extends Thread {
     
    3333        }
    3434        public static void helper() throws InterruptedException {
    35                 for(int i = 1; i <= times; i += 1) {
     35                for(long i = 1; i <= times; i += 1) {
    3636                        MyThread m = new MyThread();
    3737                        x = nextRandom( x );
     
    4747        }
    4848        public static void main(String[] args) throws InterruptedException {
    49                 if ( args.length > 2 ) System.exit( 1 );
    50                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     49                if ( args.length > 1 ) System.exit( 1 );
     50                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    5151
    52                 for (int i = Integer.parseInt("5"); --i >= 0 ; ) { 
     52                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
    5353                        InnerMain();
    5454                        Thread.sleep(2000);             // 2 seconds
  • benchmark/ctxswitch/JavaThread.java

    rae2c27a rc76bd34  
    11public class JavaThread {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        private static int nextRandom (int x) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("100000");
     28        static private long times = Long.parseLong("100000");
    2929
    3030        public static void helper() {
    31                 for(int i = 1; i <= times; i += 1) {
     31                for(long i = 1; i <= times; i += 1) {
    3232                        Thread.yield();
    3333                }
     
    4040        }
    4141        public static void main(String[] args) throws InterruptedException {
    42                 if ( args.length > 2 ) System.exit( 1 );
    43                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     42                if ( args.length > 1 ) System.exit( 1 );
     43                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    4444
    4545                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
  • benchmark/io/http/filecache.cfa

    rae2c27a rc76bd34  
    7373        cache_line * entries;
    7474        size_t size;
     75        int * rawfds;
     76        int nfds;
    7577} file_cache;
    7678
     
    98100}
    99101
    100 int put_file( cache_line & entry ) {
     102int put_file( cache_line & entry, int fd ) {
    101103        uint32_t idx = murmur3_32( (const uint8_t *)entry.file, strlen(entry.file), options.file_cache.hash_seed ) % file_cache.size;
    102104
     
    108110
    109111        file_cache.entries[idx] = entry;
     112        file_cache.entries[idx].fd = fd;
    110113        return i > 0 ? 1 : 0;
    111114}
     
    121124        size_t fcount = 0;
    122125        size_t fsize = 16;
    123         cache_line * raw = 0p;
    124         raw = alloc(raw, fsize, true);
     126        cache_line * raw = alloc(fsize);
    125127        // Step 1 get a dense array of all files
    126128        int walk(const char *fpath, const struct stat *sb, int typeflag) {
     
    131133                if(fcount > fsize) {
    132134                        fsize *= 2;
    133                         raw = alloc(raw, fsize, true);
     135                        raw = alloc(fsize, raw`realloc);
    134136                }
    135137
     
    162164        file_cache.entries = anew(file_cache.size);
    163165
     166        if(options.file_cache.fixed_fds) {
     167                file_cache.nfds   = fcount;
     168                file_cache.rawfds = alloc(fcount);
     169        }
     170
    164171        // Step 3 fill the cache
    165172        int conflicts = 0;
    166173        for(i; fcount) {
    167                 conflicts += put_file( raw[i] );
     174                int fd;
     175                if(options.file_cache.fixed_fds) {
     176                        file_cache.rawfds[i] = raw[i].fd;
     177                        fd = i;
     178                }
     179                else {
     180                        fd = raw[i].fd;
     181                }
     182                conflicts += put_file( raw[i], fd );
    168183        }
    169184        printf("Filled cache from path \"%s\" with %zu files\n", path, fcount);
     
    197212        }
    198213
    199         return [aalloc(extra), 0];
     214        size_t s = file_cache.nfds + extra;
     215        int * data = alloc(s, file_cache.rawfds`realloc);
     216        return [data, file_cache.nfds];
    200217}
    201218
  • benchmark/io/http/main.cfa

    rae2c27a rc76bd34  
    1212#include <kernel.hfa>
    1313#include <stats.hfa>
     14#include <time.hfa>
    1415#include <thread.hfa>
    1516
    16 #include "channel.hfa"
    1717#include "filecache.hfa"
    1818#include "options.hfa"
    1919#include "worker.hfa"
    2020
     21extern void register_fixed_files( cluster &, int *, unsigned count );
     22
     23Duration default_preemption() {
     24        return 0;
     25}
     26
    2127//=============================================================================================
    2228// Globals
    2329//=============================================================================================
    24 channel & wait_connect;
    25 
    2630struct ServerProc {
    2731        processor self;
     
    8488        // Run Server Cluster
    8589        {
    86                 cluster cl = { "Server Cluster", options.clopts.flags };
     90                cluster cl = { "Server Cluster", options.clopts.params };
    8791                #if !defined(__CFA_NO_STATISTICS__)
    8892                        print_stats_at_exit( cl, CFA_STATS_READY_Q | CFA_STATS_IO );
    8993                #endif
    9094                options.clopts.instance = &cl;
    91 
    92                 channel chan = { options.clopts.chan_size };
    93                 &wait_connect = &chan;
    9495
    9596                int pipe_cnt = options.clopts.nworkers * 2;
     
    102103                }
    103104
     105                if(options.file_cache.fixed_fds) {
     106                        register_fixed_files(cl, fds, pipe_off);
     107                }
     108
    104109                {
    105110                        ServerProc procs[options.clopts.nprocs];
     
    107112                                Worker workers[options.clopts.nworkers];
    108113                                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                                        // if( options.file_cache.fixed_fds ) {
     115                                        //      workers[i].pipe[0] = pipe_off + (i * 2) + 0;
     116                                        //      workers[i].pipe[1] = pipe_off + (i * 2) + 1;
     117                                        // }
     118                                        // else
     119                                        {
    114120                                                workers[i].pipe[0] = fds[pipe_off + (i * 2) + 0];
    115121                                                workers[i].pipe[1] = fds[pipe_off + (i * 2) + 1];
     122                                                workers[i].sockfd  = server_fd;
     123                                                workers[i].addr    = (struct sockaddr *)&address;
     124                                                workers[i].addrlen = (socklen_t*)&addrlen;
     125                                                workers[i].flags   = 0;
    116126                                        }
    117                                         unpark( workers[i] __cfaabi_dbg_ctx2 );
     127                                        unpark( workers[i] );
    118128                                }
    119129                                printf("%d workers started on %d processors\n", options.clopts.nworkers, options.clopts.nprocs);
    120130                                {
    121                                         Acceptor acceptor = { server_fd, (struct sockaddr *)&address, (socklen_t*)&addrlen, 0 };
    122 
    123131                                        char buffer[128];
    124132                                        while(!feof(stdin)) {
     
    127135
    128136                                        printf("Shutting Down\n");
    129                                 }
    130                                 printf("Acceptor Closed\n");
    131 
    132                                 // Clean-up the workers
    133                                 for(options.clopts.nworkers) {
    134                                         put( wait_connect, -1 );
    135137                                }
    136138                        }
  • benchmark/io/http/options.cfa

    rae2c27a rc76bd34  
    3131                1,     // nworkers;
    3232                0,     // flags;
    33                 10,    // chan_size;
    3433                false, // procstats
    3534                false, // viewhalts
     
    3938
    4039const char * parse_options( int argc, char * argv[] ) {
    41         bool uthrdpo = false;
    4240        bool subthrd = false;
    4341        bool eagrsub = false;
     
    5250                {'t', "threads",        "Number of worker threads to use", options.clopts.nworkers},
    5351                {'b', "accept-backlog", "Maximum number of pending accepts", options.socket.backlog},
    54                 {'B', "channel-size",   "Maximum number of accepted connection pending", options.clopts.chan_size},
    5552                {'r', "request_len",    "Maximum number of bytes in the http request, requests with more data will be answered with Http Code 414", options.socket.buflen},
    5653                {'S', "seed",           "seed to use for hashing", options.file_cache.hash_seed },
    5754                {'C', "cache-size",     "Size of the cache to use, if set to small, will uses closes power of 2", options.file_cache.size },
    5855                {'l', "list-files",     "List the files in the specified path and exit", options.file_cache.list, parse_settrue },
    59                 {'u', "userthread",     "If set, cluster uses user-thread to poll I/O", uthrdpo, parse_settrue },
    6056                {'s', "submitthread",   "If set, cluster uses polling thread to submit I/O", subthrd, parse_settrue },
    6157                {'e', "eagersubmit",    "If set, cluster submits I/O eagerly but still aggregates submits", eagrsub, parse_settrue},
     
    7167        parse_args( argc, argv, opt, opt_cnt, "[OPTIONS]... [PATH]\ncforall http server", left );
    7268
    73         if( uthrdpo ) {
    74                 options.clopts.flags |= CFA_CLUSTER_IO_POLLER_USER_THREAD;
    75         }
    76 
    77         if( subthrd ) {
    78                 options.clopts.flags |= CFA_CLUSTER_IO_POLLER_THREAD_SUBMITS;
    79         }
    80 
    81         if( eagrsub ) {
    82                 options.clopts.flags |= CFA_CLUSTER_IO_EAGER_SUBMITS;
    83         }
     69        options.clopts.params.poller_submits = subthrd;
     70        options.clopts.params.eager_submits  = eagrsub;
    8471
    8572        if( fixedfd ) {
     
    8875
    8976        if( sqkpoll ) {
    90                 options.clopts.flags |= CFA_CLUSTER_IO_KERNEL_POLL_SUBMITS;
     77                options.clopts.params.poll_submit = true;
    9178                options.file_cache.fixed_fds = true;
    9279        }
    9380
    9481        if( iokpoll ) {
    95                 options.clopts.flags |= CFA_CLUSTER_IO_KERNEL_POLL_COMPLETES;
     82                options.clopts.params.poll_complete = true;
    9683                options.file_cache.open_flags |= O_DIRECT;
    9784        }
    9885
    99         options.clopts.flags |= (sublen << CFA_CLUSTER_IO_BUFFLEN_OFFSET);
     86        options.clopts.params.num_ready = sublen;
    10087
    10188        if( left[0] == 0p ) { return "."; }
  • benchmark/io/http/options.hfa

    rae2c27a rc76bd34  
    22
    33#include <stdint.h>
     4
     5#include <kernel.hfa>
    46
    57struct cluster;
     
    2325                int nprocs;
    2426                int nworkers;
    25                 int flags;
    26                 int chan_size;
     27                io_context_params params;
    2728                bool procstats;
    2829                bool viewhalts;
  • benchmark/io/http/protocol.cfa

    rae2c27a rc76bd34  
    1111extern "C" {
    1212      int snprintf ( char * s, size_t n, const char * format, ... );
     13        #include <linux/io_uring.h>
    1314}
    1415#include <string.h>
    15 
    1616#include <errno.h>
    1717
     18#include "options.hfa"
    1819
    1920const char * http_msgs[] = {
     
    7475        READ:
    7576        for() {
    76                 int ret = cfa_read(fd, it, count);
    77                 if(ret == 0 ) return [OK200, true, 0p, 0];
     77                int ret = cfa_read(fd, (void*)it, count, 0, -1`s, 0p, 0p);
     78                if(ret == 0 ) return [OK200, true, 0, 0];
    7879                if(ret < 0 ) {
    7980                        if( errno == EAGAIN || errno == EWOULDBLOCK) continue READ;
     
    8889                count -= ret;
    8990
    90                 if( count < 1 ) return [E414, false, 0p, 0];
     91                if( count < 1 ) return [E414, false, 0, 0];
    9192        }
    9293
     
    9596        it = buffer;
    9697        int ret = memcmp(it, "GET /", 5);
    97         if( ret != 0 ) return [E400, false, 0p, 0];
     98        if( ret != 0 ) return [E400, false, 0, 0];
    9899        it += 5;
    99100
     
    106107        ssize_t ret;
    107108        SPLICE1: while(count > 0) {
    108                 ret = cfa_splice(ans_fd, &offset, pipe[1], 0p, count, SPLICE_F_MOVE | SPLICE_F_MORE);
     109                ret = cfa_splice(ans_fd, &offset, pipe[1], 0p, count, SPLICE_F_MOVE | SPLICE_F_MORE, 0, -1`s, 0p, 0p);
    109110                if( ret < 0 ) {
    110111                        if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE1;
     
    116117                size_t in_pipe = ret;
    117118                SPLICE2: while(in_pipe > 0) {
    118                         ret = cfa_splice(pipe[0], 0p, fd, 0p, in_pipe, SPLICE_F_MOVE | SPLICE_F_MORE);
     119                        ret = cfa_splice(pipe[0], 0p, fd, 0p, in_pipe, SPLICE_F_MOVE | SPLICE_F_MORE, 0, -1`s, 0p, 0p);
    119120                        if( ret < 0 ) {
    120121                                if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE2;
  • benchmark/io/http/worker.cfa

    rae2c27a rc76bd34  
    2222
    2323void main( Worker & this ) {
    24         park( __cfaabi_dbg_ctx );
     24        park();
    2525        /* paranoid */ assert( this.pipe[0] != -1 );
    2626        /* paranoid */ assert( this.pipe[1] != -1 );
     
    2828        CONNECTION:
    2929        for() {
    30                 int fd = take(wait_connect);
    31                 if (fd < 0) break;
     30                int fd = cfa_accept4( this.[sockfd, addr, addrlen, flags], 0, -1`s, 0p, 0p );
     31                if(fd < 0) {
     32                        if( errno == ECONNABORTED ) break;
     33                        abort( "accept error: (%d) %s\n", (int)errno, strerror(errno) );
     34                }
    3235
    3336                printf("New connection %d, waiting for requests\n", fd);
     
    8285        }
    8386}
    84 
    85 //=============================================================================================
    86 // Acceptor Thread
    87 //=============================================================================================
    88 void ?{}( Acceptor & this, int sockfd, struct sockaddr * addr, socklen_t * addrlen, int flags ) {
    89         ((thread&)this){ "Acceptor Thread", *options.clopts.instance };
    90         this.sockfd  = sockfd;
    91         this.addr    = addr;
    92         this.addrlen = addrlen;
    93         this.flags   = flags;
    94 }
    95 
    96 void main( Acceptor & this ) {
    97         for() {
    98                 int ret = cfa_accept4( this.[sockfd, addr, addrlen, flags] );
    99                 if(ret < 0) {
    100                         if( errno == ECONNABORTED ) break;
    101                         abort( "accept error: (%d) %s\n", (int)errno, strerror(errno) );
    102                 }
    103 
    104                 printf("New connection accepted\n");
    105                 put( wait_connect, ret );
    106         }
    107 }
  • benchmark/io/http/worker.hfa

    rae2c27a rc76bd34  
    77}
    88
    9 #include "channel.hfa"
    10 
    11 extern channel & wait_connect;
    12 
    139//=============================================================================================
    1410// Worker Thread
     
    1713thread Worker {
    1814        int pipe[2];
    19 };
    20 void ?{}( Worker & this );
    21 void main( Worker & );
    22 
    23 //=============================================================================================
    24 // Acceptor Thread
    25 //=============================================================================================
    26 thread Acceptor {
    2715        int sockfd;
    2816        struct sockaddr * addr;
     
    3018        int flags;
    3119};
    32 
    33 void ?{}( Acceptor & this, int sockfd, struct sockaddr * addr, socklen_t * addrlen, int flags );
    34 void main( Acceptor & this );
     20void ?{}( Worker & this);
     21void main( Worker & );
  • benchmark/io/readv.cfa

    rae2c27a rc76bd34  
    5454
    5555void main( Reader & ) {
    56         park( __cfaabi_dbg_ctx );
     56        park();
    5757        /* paranoid */ assert( true == __atomic_load_n(&run, __ATOMIC_RELAXED) );
    5858
     
    151151
    152152                                for(i; nthreads) {
    153                                         unpark( threads[i] __cfaabi_dbg_ctx2 );
     153                                        unpark( threads[i] );
    154154                                }
    155155                                wait(duration, start, end, is_tty);
  • benchmark/mutex/JavaThread.java

    rae2c27a rc76bd34  
    11public class JavaThread {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        private static int nextRandom (int x) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("100000000");
     28        static private long times = Long.parseLong("100000000");
    2929
    3030        public synchronized void noop() {
     
    3434                JavaThread j = new JavaThread();
    3535                // Inhibit biased locking ...
    36                 x = (j.hashCode() ^ System.identityHashCode(j)) | 1 ;     
    37                 for(int i = 1; i <= times; i += 1) {
     36                x = (j.hashCode() ^ System.identityHashCode(j)) | 1 ;
     37                for(long i = 1; i <= times; i += 1) {
    3838                        x = nextRandom(x);
    3939                        j.noop();
     
    4747        }
    4848        public static void main(String[] args) throws InterruptedException {
    49                 if ( args.length > 2 ) System.exit( 1 );
    50                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     49                if ( args.length > 1 ) System.exit( 1 );
     50                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    5151
    52                 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 
     52                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    5353                        InnerMain();
    5454                        Thread.sleep(2000);     // 2 seconds
  • benchmark/mutexC/JavaThread.java

    rae2c27a rc76bd34  
    11class Noop {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        public static int nextRandom( int x ) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626}
     
    4747        static int x = 2;
    4848
    49         static private int times = Integer.parseInt("10000000");
     49        static private long times = Long.parseLong("10000000");
    5050
    5151        public static void call( Monitor m ) throws InterruptedException {
     
    5353                m.go = true;
    5454                //while ( ! m.go2 );
    55                 for ( int i = 0; i < times; i += 1 ) {
     55                for ( long i = 0; i < times; i += 1 ) {
    5656                        m.call();
    5757                        x = Noop.nextRandom( x );
     
    7171        public static void main( String[] args ) throws InterruptedException {
    7272                if ( args.length > 2 ) System.exit( 1 );
    73                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     73                if ( args.length == 2 ) { times = Long.parseLong(args[1]); }
    7474
    75                 if ( args.length > 2 ) System.exit( 1 );
    76                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
    77 
    78                 for ( int i = Integer.parseInt("5"); --i >= 0 ; ) {
     75                for ( int i = Integer.parseInt("5"); --i >= 0 ; ) {
    7976                        InnerMain();
    8077                        // Thread.sleep(2000);  // 2 seconds
  • benchmark/readyQ/yield.cfa

    rae2c27a rc76bd34  
    3232
    3333void main( Yielder & this ) {
    34         park( __cfaabi_dbg_ctx );
     34        park();
    3535        /* paranoid */ assert( true == __atomic_load_n(&run, __ATOMIC_RELAXED) );
    3636
     
    7070
    7171                                for(i; nthreads) {
    72                                         unpark( threads[i] __cfaabi_dbg_ctx2 );
     72                                        unpark( threads[i] );
    7373                                }
    7474                                wait(duration, start, end, is_tty);
  • benchmark/schedint/JavaThread.java

    rae2c27a rc76bd34  
    2424public class JavaThread {
    2525        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    26         // Bijective   
     26        // Bijective
    2727        // Cycle length for non-zero values is 4G-1.
    2828        // 0 is absorbing and should be avoided -- fixed point.
    2929        // The returned value is typically masked to produce a positive value.
    30         static volatile int Ticket = 0 ; 
     30        static volatile int Ticket = 0 ;
    3131
    3232        private static int nextRandom (int x) {
    33                 if (x == 0) { 
     33                if (x == 0) {
    3434                        // reseed the PRNG
    35                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    36                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    37                         // If the race is a concern switch to an AtomicInteger. 
    38                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    39                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    40                         // nextRandom() invocations. 
    41                         x = ++Ticket ; 
    42                         if (x == 0) x = 1 ; 
     35                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     36                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     37                        // If the race is a concern switch to an AtomicInteger.
     38                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     39                        // (readily) predictable at compile-time so the JIT will not be able to elide
     40                        // nextRandom() invocations.
     41                        x = ++Ticket ;
     42                        if (x == 0) x = 1 ;
    4343                }
    4444                x ^= x << 6;
    4545                x ^= x >>> 21;
    4646                x ^= x << 7;
    47                 return x ;   
     47                return x ;
    4848        }
    4949        static int x = 2;
    5050
    51         static private int times = Integer.parseInt("1000000");
     51        static private long times = Long.parseLong("1000000");
    5252
    5353        public static void helper( Monitor m ) throws InterruptedException {
    54                 for(int i = 1; i <= times; i += 1) {
     54                for(long i = 1; i <= times; i += 1) {
    5555                        m.wait();               // relase monitor lock
    5656                        m.next = true;
     
    7575        }
    7676        public static void main(String[] args) throws InterruptedException {
    77                 if ( args.length > 2 ) System.exit( 1 );
    78                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     77                if ( args.length > 1 ) System.exit( 1 );
     78                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    7979
    80                 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 
     80                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    8181                        InnerMain();
    8282                        Thread.sleep(2000);     // 2 seconds
Note: See TracChangeset for help on using the changeset viewer.