Increase buffer pool size for enb

master
Ismael Gomez 7 years ago
parent efea8f4436
commit a2615628aa

@ -56,8 +56,12 @@ class buffer_pool{
public: public:
// non-static methods // non-static methods
buffer_pool(uint32_t nof_buffers = POOL_SIZE) buffer_pool(int capacity_ = -1)
{ {
uint32_t nof_buffers = POOL_SIZE;
if (capacity > 0) {
nof_buffers = (uint32_t) capacity_;
}
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
for(uint32_t i=0;i<nof_buffers;i++) { for(uint32_t i=0;i<nof_buffers;i++) {
buffer_t *b = new buffer_t; buffer_t *b = new buffer_t;
@ -162,10 +166,10 @@ class byte_buffer_pool {
public: public:
// Singleton static methods // Singleton static methods
static byte_buffer_pool *instance; static byte_buffer_pool *instance;
static byte_buffer_pool* get_instance(void); static byte_buffer_pool* get_instance(int capacity = -1);
static void cleanup(void); static void cleanup(void);
byte_buffer_pool() { byte_buffer_pool(int capacity = -1) {
pool = new buffer_pool<byte_buffer_t>; pool = new buffer_pool<byte_buffer_t>(capacity);
} }
~byte_buffer_pool() { ~byte_buffer_pool() {
delete pool; delete pool;
@ -178,7 +182,9 @@ public:
return; return;
} }
b->reset(); b->reset();
pool->deallocate(b); if (!pool->deallocate(b)) {
fprintf(stderr, "Error deallocating PDU: Addr=0x%lx not found in pool\n", (uint64_t) b);
}
b = NULL; b = NULL;
} }
void print_all_buffers() { void print_all_buffers() {

@ -35,11 +35,13 @@ namespace srslte{
byte_buffer_pool *byte_buffer_pool::instance = NULL; byte_buffer_pool *byte_buffer_pool::instance = NULL;
pthread_mutex_t instance_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t instance_mutex = PTHREAD_MUTEX_INITIALIZER;
byte_buffer_pool* byte_buffer_pool::get_instance(void) byte_buffer_pool* byte_buffer_pool::get_instance(int capacity)
{ {
pthread_mutex_lock(&instance_mutex); pthread_mutex_lock(&instance_mutex);
if(NULL == instance) if(NULL == instance) {
instance = new byte_buffer_pool(); printf("Creating buffer pool capacity=%d\n", capacity);
instance = new byte_buffer_pool(capacity);
}
pthread_mutex_unlock(&instance_mutex); pthread_mutex_unlock(&instance_mutex);
return instance; return instance;
} }

@ -173,6 +173,8 @@ public:
private: private:
static enb *instance; static enb *instance;
const static int ENB_POOL_SIZE = 1024*10;
enb(); enb();
virtual ~enb(); virtual ~enb();

@ -55,7 +55,7 @@ void enb::cleanup(void)
enb::enb() : started(false) { enb::enb() : started(false) {
srslte_dft_load(); srslte_dft_load();
pool = srslte::byte_buffer_pool::get_instance(); pool = srslte::byte_buffer_pool::get_instance(ENB_POOL_SIZE);
logger = NULL; logger = NULL;
args = NULL; args = NULL;

Loading…
Cancel
Save