Ignore:
Timestamp:
02/27/15 17:31:03 (7 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
  • lib/trace_parallel.c

    r7718e54 r0ec8a7c  
    385385                                  libtrace_packet_t **packet,
    386386                                  bool tracetime) {
     387
    387388        if ((*packet)->error > 0) {
    388389                if (tracetime) {
     
    391392                }
    392393                t->accepted_packets++;
    393                 *packet = (*trace->per_pkt)(trace, *packet, NULL, t);
     394                libtrace_generic_t data = {.pkt = *packet};
     395                *packet = (*trace->per_pkt)(trace, t, MESSAGE_PACKET, data, t);
    394396                trace_fin_packet(*packet);
    395397        } else {
    396                 libtrace_message_t message;
    397398                assert((*packet)->error == READ_TICK);
    398                 message.code = MESSAGE_TICK;
    399                 message.additional.uint64 = trace_packet_get_order(*packet);
    400                 message.sender = t;
    401                 (*trace->per_pkt)(trace, NULL, &message, t);
     399                libtrace_generic_t data = {.uint64 = trace_packet_get_order(*packet)};
     400                (*trace->per_pkt)(trace, t, MESSAGE_TICK, data, t);
    402401        }
    403402        return 0;
     
    462461                                     libtrace_packet_t *packets[],
    463462                                     int nb_packets, int *empty, int *offset) {
    464         libtrace_message_t message = {0};
    465463        libtrace_packet_t * packet = NULL;
    466464
    467465        /* Let the user thread know we are going to pause */
    468         message.code = MESSAGE_PAUSING;
    469         message.sender = t;
    470         (*trace->per_pkt)(trace, NULL, &message, t);
     466        (*trace->per_pkt)(trace, t, MESSAGE_PAUSING, (libtrace_generic_t){0}, t);
    471467
    472468        /* Send through any remaining packets (or messages) without delay */
     
    511507        /* Now we do the actual pause, this returns when we resumed */
    512508        trace_thread_pause(trace, t);
    513         message.code = MESSAGE_RESUMING;
    514         (*trace->per_pkt)(trace, NULL, &message, t);
     509        (*trace->per_pkt)(trace, t, MESSAGE_RESUMING, (libtrace_generic_t){0}, t);
    515510        return 1;
    516511}
     
    558553
    559554        /* Let the per_packet function know we have started */
    560         message.code = MESSAGE_STARTING;
    561         message.sender = t;
    562         (*trace->per_pkt)(trace, NULL, &message, t);
    563         message.code = MESSAGE_RESUMING;
    564         (*trace->per_pkt)(trace, NULL, &message, t);
    565 
     555        (*trace->per_pkt)(trace, t, MESSAGE_STARTING, (libtrace_generic_t){0}, t);
     556        (*trace->per_pkt)(trace, t, MESSAGE_RESUMING, (libtrace_generic_t){0}, t);
    566557
    567558        for (;;) {
     
    586577                                        goto eof;
    587578                        }
    588                         (*trace->per_pkt)(trace, NULL, &message, t);
     579                        (*trace->per_pkt)(trace, t, message.code, message.additional, message.sender);
    589580                        /* Continue and the empty messages out before packets */
    590581                        continue;
     
    653644
    654645        // Let the per_packet function know we have stopped
    655         message.code = MESSAGE_PAUSING;
    656         message.sender = t;
    657         (*trace->per_pkt)(trace, NULL, &message, t);
    658         message.code = MESSAGE_STOPPING;
    659         message.additional.uint64 = 0;
    660         (*trace->per_pkt)(trace, NULL, &message, t);
     646        (*trace->per_pkt)(trace, t, MESSAGE_PAUSING, (libtrace_generic_t){0}, t);
     647        (*trace->per_pkt)(trace, t, MESSAGE_STOPPING, (libtrace_generic_t){0}, t);
    661648
    662649        // Free any remaining packets
     
    21012088        return result->key;
    21022089}
    2103 DLLEXPORT void libtrace_result_set_value(libtrace_result_t * result, libtrace_generic_types_t value) {
     2090DLLEXPORT void libtrace_result_set_value(libtrace_result_t * result, libtrace_generic_t value) {
    21042091        result->value = value;
    21052092}
    2106 DLLEXPORT libtrace_generic_types_t libtrace_result_get_value(libtrace_result_t * result) {
     2093DLLEXPORT libtrace_generic_t libtrace_result_get_value(libtrace_result_t * result) {
    21072094        return result->value;
    21082095}
    2109 DLLEXPORT void libtrace_result_set_key_value(libtrace_result_t * result, uint64_t key, libtrace_generic_types_t value) {
     2096DLLEXPORT void libtrace_result_set_key_value(libtrace_result_t * result, uint64_t key, libtrace_generic_t value) {
    21102097        result->key = key;
    21112098        result->value = value;
     
    21552142 * Should only be called by a perpkt thread, i.e. from a perpkt handler
    21562143 */
    2157 DLLEXPORT void trace_publish_result(libtrace_t *libtrace, libtrace_thread_t *t, uint64_t key, libtrace_generic_types_t value, int type) {
     2144DLLEXPORT void trace_publish_result(libtrace_t *libtrace, libtrace_thread_t *t, uint64_t key, libtrace_generic_t value, int type) {
    21582145        libtrace_result_t res;
    21592146        res.type = type;
     
    21682155 * Sets a combiner function against the trace.
    21692156 */
    2170 DLLEXPORT void trace_set_combiner(libtrace_t *trace, const libtrace_combine_t *combiner, libtrace_generic_types_t config){
     2157DLLEXPORT void trace_set_combiner(libtrace_t *trace, const libtrace_combine_t *combiner, libtrace_generic_t config){
    21712158        if (combiner) {
    21722159                trace->combiner = *combiner;
Note: See TracChangeset for help on using the changeset viewer.