Ignore:
Timestamp:
Feb 19, 2021, 3:10:10 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:
4c4d854
Parents:
4f762d3
Message:

Fixed statistic for new io approach

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/io.cfa

    r4f762d3 rd60d30e  
    1717
    1818#if defined(__CFA_DEBUG__)
    19         #define __CFA_DEBUG_PRINT_IO__
    20         #define __CFA_DEBUG_PRINT_IO_CORE__
     19        // #define __CFA_DEBUG_PRINT_IO__
     20        // #define __CFA_DEBUG_PRINT_IO_CORE__
    2121#endif
    2222
     
    8383//=============================================================================================
    8484        static int __io_uring_enter( struct $io_context & ctx, unsigned to_submit, bool get ) {
     85                __STATS__( false, io.calls.count++; )
    8586                bool need_sys_to_submit = false;
    8687                bool need_sys_to_complete = false;
     
    109110                if( need_sys_to_submit || need_sys_to_complete ) {
    110111                        __cfadbg_print_safe(io_core, "Kernel I/O : IO_URING enter %d %u %u\n", ctx.fd, to_submit, flags);
     112                        __STATS__( false, io.calls.blocks++; )
    111113                        ret = syscall( __NR_io_uring_enter, ctx.fd, to_submit, 0, flags, (sigset_t *)0p, _NSIG / 8);
    112114                        __cfadbg_print_safe(io_core, "Kernel I/O : IO_URING %d returned %d\n", ctx.fd, ret);
     
    124126        static inline __u32 __release_sqes( struct $io_context & );
    125127
    126         static [int, bool] __drain_io( & struct  $io_context ctx ) {
     128        static bool __drain_io( struct  $io_context & ctx ) {
    127129                unsigned to_submit = __flush( ctx );
    128130                int ret = __io_uring_enter( ctx, to_submit, true );
     
    132134                        case EINTR:
    133135                        case EBUSY:
    134                                 return [0, true];
     136                                // Update statistics
     137                                __STATS__( false, io.calls.errors.busy ++; )
     138                                return true;
    135139                                break;
    136140                        default:
     
    141145                // update statistics
    142146                if (to_submit > 0) {
    143                         __STATS__( false,
    144                                 if( to_submit > 0 ) {
    145                                         io.submit_q.submit_avg.rdy += to_submit;
    146                                         io.submit_q.submit_avg.csm += ret;
    147                                         io.submit_q.submit_avg.cnt += 1;
    148                                 }
    149                         )
     147                        __STATS__( false, io.calls.submitted += ret; )
    150148                        /* paranoid */ verify( ctx.sq.to_submit <= *ctx.sq.num );
    151149
     
    170168                // Nothing was new return 0
    171169                if (head == tail) {
    172                         return [0, to_submit > 0];
     170                        return ctx.sq.to_submit > 0;
    173171                }
    174172
    175173                __u32 count = tail - head;
    176174                /* paranoid */ verify( count != 0 );
     175                __STATS__( false, io.calls.submitted += count; )
     176
    177177                for(i; count) {
    178178                        unsigned idx = (head + i) & mask;
     
    195195                __atomic_store_n( ctx.cq.head, head + count, __ATOMIC_SEQ_CST );
    196196
    197                 return [count, count > 0 || to_submit > 0];
     197                return count > 0 || to_submit > 0;
    198198        }
    199199
     
    212212
    213213                        // Drain the io
    214                         int count;
    215                         bool again;
    216                         [count, again] = __drain_io( this );
     214                        bool again = __drain_io( this );
    217215
    218216                        if(!again) reset--;
    219 
    220                         // Update statistics
    221                         __STATS__( false,
    222                                 io.complete_q.completed_avg.val += count;
    223                                 io.complete_q.completed_avg.cnt += 1;
    224                         )
    225217
    226218                        // If we got something, just yield and check again
     
    241233
    242234                        __STATS__( false,
    243                                 io.complete_q.blocks += 1;
     235                                io.calls.blocks += 1;
    244236                        )
    245237                        __cfadbg_print_safe(io_core, "Kernel I/O : Parking io poller %d (%p)\n", this.fd, &this);
     
    342334                                // Mark the instance as no longer in-use and re-enable interrupts
    343335                                __atomic_store_n( &proc->io.lock, false, __ATOMIC_RELEASE );
     336                                __STATS__( true, io.alloc.fast += 1; )
    344337                                enable_interrupts( __cfaabi_dbg_ctx );
    345338
     
    350343                        }
    351344                        // The fast path failed, fallback
     345                        __STATS__( true, io.alloc.fail += 1; )
    352346                }
    353347
    354348                // Fast path failed, fallback on arbitration
    355349                __atomic_store_n( &proc->io.lock, false, __ATOMIC_RELEASE );
     350                __STATS__( true, io.alloc.slow += 1; )
    356351                enable_interrupts( __cfaabi_dbg_ctx );
    357352
     
    409404                        // Mark the instance as no longer in-use, re-enable interrupts and return
    410405                        __atomic_store_n( &proc->io.lock, false, __ATOMIC_RELEASE );
     406                        __STATS__( true, io.submit.fast += 1; )
    411407                        enable_interrupts( __cfaabi_dbg_ctx );
    412408
     
    417413                // Fast path failed, fallback on arbitration
    418414                __atomic_store_n( &proc->io.lock, false, __ATOMIC_RELEASE );
     415                __STATS__( true, io.submit.slow += 1; )
    419416                enable_interrupts( __cfaabi_dbg_ctx );
    420417
     
    556553                        __revoke( this, c );
    557554
     555                        __STATS__( false, io.alloc.revoke += 1; )
     556
    558557                        if(__alloc(c, idxs, want)) {
    559558                                __assign( this, c, proc);
     
    564563                __cfadbg_print_safe(io, "Kernel I/O : waiting for available resources\n");
    565564
     565                __STATS__( false, io.alloc.block += 1; )
     566
    566567                // No one has any resources left, wait for something to finish
    567568                // Mark as pending
     
    626627        static void __ioarbiter_flush( $io_arbiter & mutex this, $io_context * ctx ) {
    627628                /* paranoid */ verify( &this == ctx->arbiter );
     629
     630                __STATS__( false, io.flush.external += 1; )
    628631
    629632                __revoke( this, ctx );
Note: See TracChangeset for help on using the changeset viewer.