Navigation


Changeset 1067:23989d6c8390 in freeDiameter


Ignore:
Timestamp:
Apr 30, 2013, 10:51:09 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Add total count in the statistics of the queues, thanks for the feedback :)

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdcore.h

    r1063 r1067  
    10261026 *  max           : (out) The max number of items the queue accepts before becoming blocking -- 0 means no max.
    10271027 *  highest_count : (out) The highest count the queue has reached since startup
     1028 *  total_count   : (out) Total number of items that this queue has processed (always growing, use deltas for monitoring)
    10281029 *  total         : (out) Cumulated time all items spent in this queue, including blocking time (always growing, use deltas for monitoring)
    10291030 *  blocking      : (out) Cumulated time threads trying to post new items were blocked (queue full).
     
    10391040 */
    10401041int fd_stat_getstats(enum fd_stat_type stat, struct peer_hdr * peer,
    1041                         int * len, int * max, int * highest_count,
     1042                        int * len, int * max, int * highest_count, long long * total_count,
    10421043                        struct timespec * total, struct timespec * blocking, struct timespec * last);
    10431044
  • include/freeDiameter/libfdproto.h

    r1060 r1067  
    30543054 * PARAMETERS:
    30553055 *  queue       : The queue from which to retrieve the timings information.
     3056 *  items       : the total number of items that went through the queue (already pop'd). Always increasing.
    30563057 *  total       : Cumulated time all items spent in this queue, including blocking time (always growing, use deltas for monitoring)
    30573058 *  blocking    : Cumulated time threads trying to post new items were blocked (queue full).
     
    30653066 *  EINVAL      : A parameter is invalid.
    30663067 */
    3067 int fd_fifo_getstats( struct fifo * queue, struct timespec * total, struct timespec * blocking, struct timespec * last);
     3068int fd_fifo_getstats( struct fifo * queue, long long *items, struct timespec * total, struct timespec * blocking, struct timespec * last);
    30683069
    30693070
  • libfdproto/fifo.c

    r1060 r1067  
    7171        int             highest_ever; /* The max count value this queue has reached (for tweaking) */
    7272       
     73        long long       total_items;   /* Cumulated number of items that went through this fifo (excluding current count), always increasing. */
    7374        struct timespec total_time;    /* Cumulated time all items spent in this queue, including blocking time (always growing, use deltas for monitoring) */
    7475        struct timespec blocking_time; /* Cumulated time threads trying to post new items were blocked (queue full). */
     
    140141                        queue->h_cb, queue->l_cb, queue->data,
    141142                        queue->highest_ever);
    142         fd_log_debug("   timings: total:%ld.%06ld, blocking:%ld.%06ld, last:%ld.%06ld",
    143                         (long)queue->total_time.tv_sec,(long)(queue->total_time.tv_nsec/1000),
     143        fd_log_debug("   stats: total:%lld in %ld.%06ld, blocking:%ld.%06ld, last:%ld.%06ld",
     144                        queue->total_items,
     145                        (long)queue->total_time.tv_sec,(long)(queue->total_time.tv_nsec/1000),
    144146                        (long)queue->blocking_time.tv_sec,(long)(queue->blocking_time.tv_nsec/1000),
    145147                        (long)queue->last_time.tv_sec,(long)(queue->last_time.tv_nsec/1000) );
     
    259261        old->eyec = FIFO_EYEC;
    260262       
     263        /* Merge the stats in the new queue */
     264        new->total_items += old->total_items;
     265        old->total_items = 0;
     266       
     267        new->total_time.tv_nsec += old->total_time.tv_nsec;
     268        new->total_time.tv_sec += old->total_time.tv_sec + (new->total_time.tv_nsec / 1000000000);
     269        new->total_time.tv_nsec %= 1000000000;
     270        old->total_time.tv_nsec = 0;
     271        old->total_time.tv_sec = 0;
     272       
     273        new->blocking_time.tv_nsec += old->blocking_time.tv_nsec;
     274        new->blocking_time.tv_sec += old->blocking_time.tv_sec + (new->blocking_time.tv_nsec / 1000000000);
     275        new->blocking_time.tv_nsec %= 1000000000;
     276        old->blocking_time.tv_nsec = 0;
     277        old->blocking_time.tv_sec = 0;
     278       
    261279        /* Unlock, we're done */
    262280        CHECK_POSIX(  pthread_mutex_unlock( &new->mtx )  );
     
    291309
    292310/* Get the timings */
    293 int fd_fifo_getstats( struct fifo * queue, struct timespec * total, struct timespec * blocking, struct timespec * last)
    294 {
    295         TRACE_ENTRY( "%p %p %p %p", queue, total, blocking, last);
     311int fd_fifo_getstats( struct fifo * queue, long long *items, struct timespec * total, struct timespec * blocking, struct timespec * last)
     312{
     313        TRACE_ENTRY( "%p %p %p %p %p", queue, items, total, blocking, last);
    296314       
    297315        /* Check the parameters */
     
    300318        /* lock the queue */
    301319        CHECK_POSIX(  pthread_mutex_lock( &queue->mtx )  );
     320       
     321        if (items)
     322                *items = queue->total_items;
    302323       
    303324        if (total)
     
    467488        fd_list_unlink(&fi->item);
    468489        queue->count--;
     490        queue->total_items++;
    469491        ret = fi->item.o;
    470492       
Note: See TracChangeset for help on using the changeset viewer.