Repository: kudu Updated Branches: refs/heads/master 3b51bf337 -> c497c69bb
consensus: avoid extra thread wakeups for Peer::SignalRequest Looking at a profile on a YCSB workload I see a significant amount of CPU in submitting tasks to the raft threadpool for requests. My guess is that, in a workload like this, we often call SignalRequest while the request was already pending. This patch avoids submitting the threadpool task if there is already a task pending. Change-Id: I62ec4ea91e976590ce2de4fa34db61eaf9aab92a Reviewed-on: http://gerrit.cloudera.org:8080/9092 Tested-by: Kudu Jenkins Reviewed-by: David Ribeiro Alves <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/9961902d Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/9961902d Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/9961902d Branch: refs/heads/master Commit: 9961902d8b4f18a5e5d68aeb624e27167651b837 Parents: 3b51bf3 Author: Todd Lipcon <[email protected]> Authored: Mon Jan 22 08:13:15 2018 -0800 Committer: Todd Lipcon <[email protected]> Committed: Wed Jan 24 19:07:17 2018 +0000 ---------------------------------------------------------------------- src/kudu/consensus/consensus_peers.cc | 6 ++++++ 1 file changed, 6 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/9961902d/src/kudu/consensus/consensus_peers.cc ---------------------------------------------------------------------- diff --git a/src/kudu/consensus/consensus_peers.cc b/src/kudu/consensus/consensus_peers.cc index 6d68528..187ed6f 100644 --- a/src/kudu/consensus/consensus_peers.cc +++ b/src/kudu/consensus/consensus_peers.cc @@ -167,6 +167,12 @@ Status Peer::SignalRequest(bool even_if_queue_empty) { return Status::IllegalState("Peer was closed."); } + // Only allow one request at a time. No sense waking up the + // raft thread pool if the task will just abort anyway. + if (request_pending_) { + return Status::OK(); + } + // Capture a weak_ptr reference into the submitted functor so that we can // safely handle the functor outliving its peer. weak_ptr<Peer> w_this = shared_from_this();
