Changeset adb2c4c


Ignore:
Timestamp:
12/05/16 19:34:30 (4 years ago)
Author:
Richard Sanger <rsanger@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, master, ndag_format, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
f8613e4
Parents:
5e3f16c
Message:

Remove mutex in the packet path, which limits parallel performance

Packets should be destroyed (or finished) before the format is closed,
however this was never enforced or implemented in the single threaded API.

As such to provide support for old applications that destroy the packet
after the trace we store the packet against the trace. This was a race
and locks were used for safety even when using the parallel API.

Instead of locks we can assume that the parallel API will destroy
packets before the trace is closed. So instead of locks only store
the packet in the single threaded case.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    r5e3f16c radb2c4c  
    550550
    551551        /* Finish the last packet we read - for backwards compatibility */
    552         if (libtrace->last_packet)
     552        if (!libtrace_parallel && libtrace->last_packet)
    553553                trace_fin_packet(libtrace->last_packet);
    554554        assert(libtrace->last_packet == NULL);
     
    697697
    698698        /* Finish any the last packet we read - for backwards compatibility */
    699         if (libtrace->last_packet) {
     699        if (!libtrace_parallel && libtrace->last_packet) {
    700700                trace_fin_packet(libtrace->last_packet);
    701701        }
     
    837837                packet->trace->format->fin_packet(packet);
    838838        }
    839         if (packet->trace && packet->trace->last_packet == packet)
     839        if (!libtrace_parallel && packet->trace &&
     840             packet->trace->last_packet == packet) {
    840841                packet->trace->last_packet = NULL;
     842        }
    841843       
    842844        if (packet->buf_control == TRACE_CTRL_PACKET && packet->buffer) {
     
    868870
    869871                if (packet->trace) {
    870                         pthread_mutex_lock(&packet->trace->libtrace_lock);
    871                         if (packet->trace->last_packet == packet)
    872                                 packet->trace->last_packet = NULL;
    873                         pthread_mutex_unlock(&packet->trace->libtrace_lock);
     872                        if (!libtrace_parallel && packet->trace->last_packet == packet)
     873                                packet->trace->last_packet = NULL;
    874874                }
    875875
     
    960960                        ++libtrace->accepted_packets;
    961961                        ++libtrace->sequence_number;
    962                         if (packet->trace == libtrace)
     962                        if (!libtrace_parallel && packet->trace == libtrace)
    963963                                libtrace->last_packet = packet;
    964964
     
    10031003
    10041004        packet->trace = trace;
    1005         pthread_mutex_lock(&trace->libtrace_lock);
    1006         trace->last_packet = packet;
    1007         pthread_mutex_unlock(&trace->libtrace_lock);
     1005        if (!libtrace_parallel)
     1006                trace->last_packet = packet;
    10081007        /* Clear packet cache */
    10091008        trace_clear_cache(packet);
Note: See TracChangeset for help on using the changeset viewer.