Index: src/circular-queue.cc |
diff --git a/src/circular-queue.cc b/src/circular-queue.cc |
index 928c3f0c05ecf8d09b3112cf6c7e5cbab0990bb8..aed71790c0023eaa3b83bbc41f27d6d89f5d0b73 100644 |
--- a/src/circular-queue.cc |
+++ b/src/circular-queue.cc |
@@ -35,16 +35,13 @@ namespace internal { |
SamplingCircularQueue::SamplingCircularQueue(int record_size_in_bytes, |
int desired_chunk_size_in_bytes, |
- int buffer_size_in_chunks) |
+ int buffer_size_in_chunks, |
+ int producer_consumer_distance) |
loislo
2013/02/21 12:42:39
I'd pass a boolean or enum flag instead of a magic
yurys
2013/02/21 12:45:48
Done.
|
: record_size_(record_size_in_bytes / sizeof(Cell)), |
chunk_size_in_bytes_(desired_chunk_size_in_bytes / record_size_in_bytes * |
record_size_in_bytes), |
chunk_size_(chunk_size_in_bytes_ / sizeof(Cell)), |
buffer_size_(chunk_size_ * buffer_size_in_chunks), |
- // The distance ensures that producer and consumer never step on |
- // each other's chunks and helps eviction of produced data from |
- // the CPU cache (having that chunk size is bigger than the cache.) |
- producer_consumer_distance_(2 * chunk_size_), |
buffer_(NewArray<Cell>(buffer_size_ + 1)) { |
ASSERT(buffer_size_in_chunks > 2); |
// Clean up the whole buffer to avoid encountering a random kEnd |
@@ -74,7 +71,11 @@ SamplingCircularQueue::SamplingCircularQueue(int record_size_in_bytes, |
ASSERT(reinterpret_cast<byte*>(consumer_pos_ + 1) <= |
positions_ + positions_size); |
consumer_pos_->dequeue_chunk_pos = buffer_; |
- consumer_pos_->dequeue_chunk_poll_pos = buffer_ + producer_consumer_distance_; |
+ // The distance ensures that producer and consumer never step on |
+ // each other's chunks and helps eviction of produced data from |
+ // the CPU cache (having that chunk size is bigger than the cache.) |
+ producer_consumer_distance *= chunk_size_; |
+ consumer_pos_->dequeue_chunk_poll_pos = buffer_ + producer_consumer_distance; |
consumer_pos_->dequeue_pos = NULL; |
} |