From c1abe0e573275da7085dca1b82d8860230f8ecfe Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 17 Feb 2015 18:00:12 +0200 Subject: [PATCH] smp: remove gratuitous cache miss when no responses are pending boost::lockfree::spsc_queue::push() writes the producer index even when no data is pushed, so check whether we need to do any work beforehand. --- core/reactor.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/reactor.cc b/core/reactor.cc index 59a235e90d..e61630f957 100644 --- a/core/reactor.cc +++ b/core/reactor.cc @@ -962,8 +962,10 @@ void smp_message_queue::respond(work_item* item) { } void smp_message_queue::flush_response_batch() { - _completed.push(_completed_fifo.begin(), _completed_fifo.end()); - _completed_fifo.clear(); + if (!_completed_fifo.empty()) { + _completed.push(_completed_fifo.begin(), _completed_fifo.end()); + _completed_fifo.clear(); + } } template