Ignore:
Timestamp:
06/23/14 13:42:35 (8 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:
014f733
Parents:
b13b939
Message:

Automatically scale threads to the number of available CPU cores on Linux.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace_parallel.c

    rb13b939 r85e87b5  
    9898#include <pthread.h>
    9999#include <signal.h>
    100 
     100#include <unistd.h>
    101101
    102102extern int libtrace_parallel;
     
    895895
    896896
    897 DLLEXPORT inline uint64_t tv_to_usec(struct timeval *tv)
     897DLLEXPORT uint64_t tv_to_usec(struct timeval *tv)
    898898{
    899899        return (uint64_t) tv->tv_sec*1000000ull + (uint64_t) tv->tv_usec;
     
    11461146                libtrace->perpkt_buffer_size = 1000;
    11471147
    1148         if (libtrace->perpkt_thread_count <= 0)
    1149                 libtrace->perpkt_thread_count = 2; // XXX scale to system
     1148        if (libtrace->perpkt_thread_count <= 0) {
     1149                // TODO add BSD support
     1150                libtrace->perpkt_thread_count = sysconf(_SC_NPROCESSORS_ONLN);
     1151                if (libtrace->perpkt_thread_count <= 0)
     1152                        // Lets just use one
     1153                        libtrace->perpkt_thread_count = 1;
     1154        }
    11501155
    11511156        if(libtrace->packet_freelist_size <= 0)
Note: See TracChangeset for help on using the changeset viewer.