Changeset 0ec8a7c for tools/tracestats


Ignore:
Timestamp:
02/27/15 17:31:03 (6 years ago)
Author:
Richard Sanger <rsangerarj@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
98dc1ba
Parents:
7718e54
Message:

Change the user interface from a message and a packet to only messages.

Now a packet is a type of message (MESSAGE_PACKET).
I expanded the message structure into seperate arguments such that these
will be passed in registers on x64 systems. As such performance has
remained identical if not better.

I renamed libtrace_generic_types_t to libtrace_generic_t so it was shorter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/tracestats/tracestats_parallel.c

    r2adc1d0 r0ec8a7c  
    102102
    103103
    104 static void* per_packet(libtrace_t *trace, libtrace_packet_t *pkt, libtrace_message_t *mesg, libtrace_thread_t *t)
     104//libtrace_message_t mesg
     105static void* per_packet(libtrace_t *trace, libtrace_thread_t *t,
     106                        int mesg, libtrace_generic_t data,
     107                        libtrace_thread_t *sender)
    105108{
    106109        // Using first entry as total and those after for filter counts
    107110        static __thread statistics_t * results = NULL;
    108         int i;
    109        
    110         if (pkt) {
    111                 int wlen = trace_get_wire_length(pkt);
     111        int i, wlen;
     112        libtrace_stat_t *stats;
     113
     114
     115        // printf ("%d.%06d READ #%"PRIu64"\n", tv.tv_sec, tv.tv_usec, trace_packet_get(packet));
     116        switch (mesg) {
     117        case MESSAGE_PACKET:
     118                wlen = trace_get_wire_length(data.pkt);
    112119                for(i=0;i<filter_count;++i) {
    113120                        if (filters[i].filter == NULL)
    114121                                continue;
    115                         if(trace_apply_filter(filters[i].filter,pkt) > 0) {
     122                        if(trace_apply_filter(filters[i].filter,data.pkt) > 0) {
    116123                                results[i+1].count++;
    117124                                results[i+1].bytes+=wlen;
     
    126133                results[0].count++;
    127134                results[0].bytes +=wlen;
    128         }
    129         if (mesg) {
    130                 // printf ("%d.%06d READ #%"PRIu64"\n", tv.tv_sec, tv.tv_usec, trace_packet_get(packet));
    131                 switch (mesg->code) {
    132                         case MESSAGE_STOPPING:
    133                                 trace_publish_result(trace, t, 0, (libtrace_generic_types_t){.ptr = results}, RESULT_NORMAL); // Only ever using a single key 0
    134                                 //fprintf(stderr, "tracestats_parallel:\t Stopping thread - publishing results\n");
    135                                 break;
    136                         case MESSAGE_STARTING:
    137                                 results = calloc(1, sizeof(statistics_t) * (filter_count + 1));
    138                                 break;
    139                         case MESSAGE_DO_PAUSE:
    140                                 assert(!"GOT Asked to pause!!!\n");
    141                                 break;
    142                         case MESSAGE_PAUSING:
    143                                 //fprintf(stderr, "tracestats_parallel:\t pausing thread\n");
    144                                 break;
    145                         case MESSAGE_RESUMING:
    146                                 //fprintf(stderr, "tracestats_parallel:\t resuming thread\n");
    147                                 break;
    148                 }
    149         }
    150         return pkt;
     135                return data.pkt;
     136        case MESSAGE_STOPPING:
     137                stats = trace_create_statistics();
     138                trace_get_thread_statistics(trace, t, stats);
     139                trace_print_statistics(stats, stderr, NULL);
     140                free(stats);
     141                trace_publish_result(trace, t, 0, (libtrace_generic_t){.ptr = results}, RESULT_NORMAL); // Only ever using a single key 0
     142                //fprintf(stderr, "tracestats_parallel:\t Stopping thread - publishing results\n");
     143                break;
     144        case MESSAGE_STARTING:
     145                results = calloc(1, sizeof(statistics_t) * (filter_count + 1));
     146                break;
     147        case MESSAGE_DO_PAUSE:
     148                assert(!"GOT Asked to pause!!!\n");
     149                break;
     150        case MESSAGE_PAUSING:
     151                //fprintf(stderr, "tracestats_parallel:\t pausing thread\n");
     152                break;
     153        case MESSAGE_RESUMING:
     154                //fprintf(stderr, "tracestats_parallel:\t resuming thread\n");
     155                break;
     156        }
     157        return NULL;
    151158}
    152159
Note: See TracChangeset for help on using the changeset viewer.