IMPALA-4465: Don't hold process wide lock while serializing Runtime Profile in GetRuntimeProfileStr()
This patch changes the code so that the query_exec_state_map_lock_ is not held while serializing the RuntimeProfile, since that is a pretty expensive operation and happens at least once per query. This change makes a lot of client calls have less lock contention including Webserver calls and query registration/unregistration. Change-Id: I3ad8a1d6644259f177dfb3b29b3ba1ad6a76210a Reviewed-on: http://gerrit.cloudera.org:8080/5035 Reviewed-by: Sailesh Mukil <[email protected]> Tested-by: Internal Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/f4a5d863 Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/f4a5d863 Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/f4a5d863 Branch: refs/heads/hadoop-next Commit: f4a5d863c3123503d8b8c89bf1415f4bbdd6a810 Parents: 628685a Author: Sailesh <[email protected]> Authored: Thu Nov 10 11:33:31 2016 -0800 Committer: Internal Jenkins <[email protected]> Committed: Tue Nov 15 03:33:14 2016 +0000 ---------------------------------------------------------------------- be/src/service/impala-server.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/f4a5d863/be/src/service/impala-server.cc ---------------------------------------------------------------------- diff --git a/be/src/service/impala-server.cc b/be/src/service/impala-server.cc index 730dfbf..c210e28 100644 --- a/be/src/service/impala-server.cc +++ b/be/src/service/impala-server.cc @@ -565,13 +565,13 @@ Status ImpalaServer::GetRuntimeProfileStr(const TUniqueId& query_id, DCHECK(output != NULL); // Search for the query id in the active query map { - lock_guard<mutex> l(query_exec_state_map_lock_); - QueryExecStateMap::const_iterator exec_state = query_exec_state_map_.find(query_id); - if (exec_state != query_exec_state_map_.end()) { + shared_ptr<QueryExecState> exec_state = GetQueryExecState(query_id, false); + if (exec_state.get() != nullptr) { + lock_guard<mutex> l(*exec_state->lock()); if (base64_encoded) { - exec_state->second->profile().SerializeToArchiveString(output); + exec_state->profile().SerializeToArchiveString(output); } else { - exec_state->second->profile().PrettyPrint(output); + exec_state->profile().PrettyPrint(output); } return Status::OK(); }
