diff options
author | Josh Blum | 2013-04-16 22:19:42 -0700 |
---|---|---|
committer | Josh Blum | 2013-04-16 22:19:42 -0700 |
commit | a832d3ba9ecd417be473257d47401f0719c1b23b (patch) | |
tree | d89aeef593a73835a14c351e59800ee25a3b8aed /lib | |
parent | 92354bdf21ca30fabbfc6e02133581f627827296 (diff) | |
download | sandhi-a832d3ba9ecd417be473257d47401f0719c1b23b.tar.gz sandhi-a832d3ba9ecd417be473257d47401f0719c1b23b.tar.bz2 sandhi-a832d3ba9ecd417be473257d47401f0719c1b23b.zip |
gras: enable half consumed metric on pool buffers
Diffstat (limited to 'lib')
-rw-r--r-- | lib/block_allocator.cpp | 3 | ||||
-rw-r--r-- | lib/buffer_queue_pool.cpp | 17 | ||||
-rw-r--r-- | lib/gras_impl/input_buffer_queues.hpp | 10 |
3 files changed, 27 insertions, 3 deletions
diff --git a/lib/block_allocator.cpp b/lib/block_allocator.cpp index bd2f3c2..fb00d58 100644 --- a/lib/block_allocator.cpp +++ b/lib/block_allocator.cpp @@ -9,13 +9,14 @@ using namespace gras; const size_t AT_LEAST_BYTES = 32*(1024); //kiB per buffer const size_t AHH_TOO_MANY_BYTES = 32*(1024*1024); //MiB enough for me -const size_t THIS_MANY_BUFFERS = 8; //pool size +const size_t THIS_MANY_BUFFERS = 2; //pool size static void buffer_returner(ThreadPool tp, Theron::Address addr, const size_t index, SBuffer &buffer) { //reset offset and length buffer.offset = 0; buffer.length = 0; + buffer.last = NULL; OutputBufferMessage message; message.index = index; diff --git a/lib/buffer_queue_pool.cpp b/lib/buffer_queue_pool.cpp index 0b2d343..79e2cc3 100644 --- a/lib/buffer_queue_pool.cpp +++ b/lib/buffer_queue_pool.cpp @@ -31,8 +31,21 @@ struct BufferQueuePool : BufferQueue void pop(void) { ASSERT(not _queue.empty()); - _queue.front().reset(); //dont hold ref - _queue.pop_front(); + SBuffer &buff = _queue.front(); + + //This little half consumed metric lets us keep using + //the same buffer if its only been partially consumed. + //Input buffer stitching will rejoin contiguous memory. + if (buff.offset > buff.get_actual_length()/2) + { + buff.reset(); //dont hold ref + _queue.pop_front(); + } + else + { + //enables buffer stitching on pool buffers + buff.last = buff.get(); + } } void push(const SBuffer &buff) diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp index 7bdbddc..e45bc06 100644 --- a/lib/gras_impl/input_buffer_queues.hpp +++ b/lib/gras_impl/input_buffer_queues.hpp @@ -282,6 +282,7 @@ GRAS_FORCE_INLINE void InputBufferQueues::push(const size_t i, const SBuffer &bu __update(i); #ifdef GRAS_ENABLE_BUFFER_STITCHING + if (_queues[i].size() <= 1) return; //stitch: for (size_t j = _queues[i].size()-1; j > 0; j--) { @@ -298,6 +299,15 @@ GRAS_FORCE_INLINE void InputBufferQueues::push(const size_t i, const SBuffer &bu b1.last = b0.get(b0.length); } } + + //back got fully stitched and it was the same buffer -> pop it + SBuffer &b1 = _queues[i].back(); + SBuffer &b0 = _queues[i][_queues[i].size()-2]; + if (b1 == b0 and b1.length == 0) + { + b1.reset(); + _queues[i].pop_back(); + } #endif //GRAS_ENABLE_BUFFER_STITCHING } |