Changeset a49a9eb for lib/trace.c


Ignore:
Timestamp:
07/30/14 18:44:16 (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:
be3f75b
Parents:
41148f2
Message:

Add an object cache with thread local caches
All packets used by a trace are put through this.
Adds bulk read/write operations to the ringbuffer (used by the object cache)
Replace semaphores with condition variables to support these bulk operations.
Internally use bulk read operations from a single threaded formats to reduce lock overhead.
Replaces the asserts around pthread_* functions with a version that will still run the command if NDEBUG

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    rc99b1e5 ra49a9eb  
    273273        libtrace->perpkt_buffer_size = 0;
    274274        libtrace->expected_key = 0;
    275         libtrace_zero_ringbuffer(&libtrace->packet_freelist);
     275        libtrace_zero_ocache(&libtrace->packet_freelist);
    276276        libtrace_zero_thread(&libtrace->hasher_thread);
    277277        libtrace_zero_thread(&libtrace->reducer_thread);
     
    395395        libtrace->packet_freelist_size = 0;
    396396        libtrace->perpkt_buffer_size = 0;
    397         libtrace_zero_ringbuffer(&libtrace->packet_freelist);
     397        libtrace_zero_ocache(&libtrace->packet_freelist);
    398398        libtrace_zero_thread(&libtrace->hasher_thread);
    399399        libtrace_zero_thread(&libtrace->reducer_thread);
     
    651651                }
    652652                free(libtrace->first_packets.packets);
    653                 assert(pthread_spin_destroy(&libtrace->first_packets.lock) == 0);
     653                ASSERT_RET(pthread_spin_destroy(&libtrace->first_packets.lock), == 0);
    654654        }
    655655
     
    666666        /* Empty any packet memory */
    667667        if (libtrace->state != STATE_NEW) {
    668                 libtrace_packet_t * packet;
    669                 while (libtrace_ringbuffer_try_read(&libtrace->packet_freelist,(void **) &packet))
    670                         trace_destroy_packet(packet);
    671                
    672                 libtrace_ringbuffer_destroy(&libtrace->packet_freelist);
     668                // This has all of our packets
     669                libtrace_ocache_destroy(&libtrace->packet_freelist);
    673670               
    674671                for (i = 0; i < libtrace->perpkt_thread_count; ++i) {
     
    721718}
    722719
    723 DLLEXPORT libtrace_packet_t *trace_create_packet(void) 
    724 {
    725         libtrace_packet_t *packet = 
     720DLLEXPORT libtrace_packet_t *trace_create_packet(void)
     721{
     722        libtrace_packet_t *packet =
    726723                (libtrace_packet_t*)calloc((size_t)1,sizeof(libtrace_packet_t));
    727724
     
    14531450#if HAVE_LLVM
    14541451        if (!filter->jitfilter) {
    1455                 assert(pthread_mutex_lock(&mutex) == 0);
     1452                ASSERT_RET(pthread_mutex_lock(&mutex), == 0);
    14561453                /* Again double check here like the bpf filter */
    14571454                if(filter->jitfilter)
     
    14621459                 * as such lock here anyways */
    14631460                        filter->jitfilter = compile_program(filter->filter.bf_insns, filter->filter.bf_len);
    1464                 assert(pthread_mutex_unlock(&mutex) == 0);
     1461                ASSERT_RET(pthread_mutex_unlock(&mutex), == 0);
    14651462        }
    14661463#endif
Note: See TracChangeset for help on using the changeset viewer.