diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-12-15 15:01:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-15 15:01:21 +0100 |
commit | 122f1f74e06e911babb60326e8c214f51e08be7f (patch) | |
tree | 6a8b78cfba19e5af8b0a89b612f23a0fa8e5c8b8 | |
parent | 8d7a5ee3e70389543bb8c819d94266acc25287a6 (diff) | |
parent | c92956a208e8243b7eb9e14eb906844a5bd01cd4 (diff) |
Merge pull request #15822 from vespa-engine/geirst/proton-thread-pools-explorer
Add explorer for the shared thread pools used by proton and it's docu…
10 files changed, 181 insertions, 43 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h index 2a7115f4d33..160423c7c68 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h +++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h @@ -112,6 +112,11 @@ public: vespalib::ThreadStackExecutor::Stats getExecutorStats() { return _executor.getStats(); } /** + * Returns the underlying executor. Only used for state explorers. + */ + const vespalib::SyncableThreadExecutor& get_executor() const { return _executor; } + + /** * Starts the scheduling thread of this manager. * * @return This, to allow chaining. diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h index 34aacdafcad..8adc198bb40 100644 --- a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h +++ b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h @@ -60,6 +60,11 @@ public: vespalib::ThreadStackExecutor::Stats getExecutorStats() { return _executor.getStats(); } /** + * Returns the underlying executor. Only used for state explorers. + */ + const vespalib::SyncableThreadExecutor& get_executor() const { return _executor; } + + /** * Closes the request handler interface. This will prevent any more data * from entering this object, allowing you to flush all pending operations * without having to safe-guard against input. diff --git a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt index 81dd8a64a6c..73b7404ce31 100644 --- a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt @@ -35,6 +35,7 @@ vespa_add_library(searchcore_server STATIC documentretrieverbase.cpp documentsubdbcollection.cpp emptysearchview.cpp + executor_explorer_utils.cpp executor_thread_service.cpp executor_threading_service_explorer.cpp executorthreadingservice.cpp @@ -77,6 +78,7 @@ vespa_add_library(searchcore_server STATIC proton_config_snapshot.cpp proton_configurer.cpp proton_disk_layout.cpp + proton_thread_pools_explorer.cpp prune_session_cache_job.cpp pruneremoveddocumentsjob.cpp putdonecontext.cpp diff --git a/searchcore/src/vespa/searchcore/proton/server/executor_explorer_utils.cpp b/searchcore/src/vespa/searchcore/proton/server/executor_explorer_utils.cpp new file mode 100644 index 00000000000..bbb87099988 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/executor_explorer_utils.cpp @@ -0,0 +1,57 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "executor_explorer_utils.h" +#include <vespa/vespalib/data/slime/cursor.h> +#include <vespa/vespalib/util/blockingthreadstackexecutor.h> +#include <vespa/vespalib/util/singleexecutor.h> +#include <vespa/vespalib/util/threadexecutor.h> +#include <vespa/vespalib/util/threadstackexecutor.h> + +using vespalib::BlockingThreadStackExecutor; +using vespalib::SingleExecutor; +using vespalib::SyncableThreadExecutor; +using vespalib::ThreadStackExecutor; +using vespalib::slime::Cursor; + + +namespace proton::explorer { + +namespace { + +void +convert_syncable_executor_to_slime(const SyncableThreadExecutor& executor, const vespalib::string& type, Cursor& object) +{ + object.setString("type", type); + object.setLong("num_threads", executor.getNumThreads()); + object.setLong("task_limit", executor.getTaskLimit()); +} + +void +convert_single_executor_to_slime(const SingleExecutor& executor, Cursor& object) +{ + convert_syncable_executor_to_slime(executor, "SingleExecutor", object); + object.setLong("watermark", executor.get_watermark()); + object.setDouble("reaction_time_sec", vespalib::to_s(executor.get_reaction_time())); +} + +} + +void +convert_executor_to_slime(const SyncableThreadExecutor* executor, Cursor& object) +{ + if (executor == nullptr) { + return; + } + if (const auto* single = dynamic_cast<const SingleExecutor*>(executor)) { + convert_single_executor_to_slime(*single, object); + } else if (const auto* blocking = dynamic_cast<const BlockingThreadStackExecutor*>(executor)) { + convert_syncable_executor_to_slime(*blocking, "BlockingThreadStackExecutor", object); + } else if (const auto* thread = dynamic_cast<const ThreadStackExecutor*>(executor)) { + convert_syncable_executor_to_slime(*thread, "ThreadStackExecutor", object); + } else { + convert_syncable_executor_to_slime(*executor, "SyncableThreadExecutor", object); + } +} + +} + diff --git a/searchcore/src/vespa/searchcore/proton/server/executor_explorer_utils.h b/searchcore/src/vespa/searchcore/proton/server/executor_explorer_utils.h new file mode 100644 index 00000000000..0793fa6ac4a --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/executor_explorer_utils.h @@ -0,0 +1,16 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +namespace vespalib { class SyncableThreadExecutor; } +namespace vespalib::slime { struct Cursor; } + +namespace proton::explorer { + +/** + * Utility to convert an executor to slime for use with a state explorer. + */ +void convert_executor_to_slime(const vespalib::SyncableThreadExecutor* executor, vespalib::slime::Cursor& object); + +} + diff --git a/searchcore/src/vespa/searchcore/proton/server/executor_threading_service_explorer.cpp b/searchcore/src/vespa/searchcore/proton/server/executor_threading_service_explorer.cpp index 0ecdca54e27..e3154ad6a47 100644 --- a/searchcore/src/vespa/searchcore/proton/server/executor_threading_service_explorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/executor_threading_service_explorer.cpp @@ -1,26 +1,21 @@ // Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include "executor_explorer_utils.h" #include "executor_threading_service_explorer.h" #include "executorthreadingservice.h" #include <vespa/vespalib/data/slime/cursor.h> #include <vespa/vespalib/util/adaptive_sequenced_executor.h> -#include <vespa/vespalib/util/blockingthreadstackexecutor.h> #include <vespa/vespalib/util/sequencedtaskexecutor.h> -#include <vespa/vespalib/util/singleexecutor.h> -#include <vespa/vespalib/util/threadexecutor.h> -#include <vespa/vespalib/util/threadstackexecutor.h> using vespalib::AdaptiveSequencedExecutor; -using vespalib::BlockingThreadStackExecutor; using vespalib::ISequencedTaskExecutor; using vespalib::SequencedTaskExecutor; -using vespalib::SingleExecutor; -using vespalib::SyncableThreadExecutor; -using vespalib::ThreadStackExecutor; using vespalib::slime::Cursor; namespace proton { +using explorer::convert_executor_to_slime; + namespace { void @@ -30,39 +25,6 @@ set_type(Cursor& object, const vespalib::string& type) } void -convert_syncable_executor_to_slime(const SyncableThreadExecutor& executor, const vespalib::string& type, Cursor& object) -{ - set_type(object, type); - object.setLong("num_threads", executor.getNumThreads()); - object.setLong("task_limit", executor.getTaskLimit()); -} - -void -convert_single_executor_to_slime(const SingleExecutor& executor, Cursor& object) -{ - convert_syncable_executor_to_slime(executor, "SingleExecutor", object); - object.setLong("watermark", executor.get_watermark()); - object.setDouble("reaction_time_sec", vespalib::to_s(executor.get_reaction_time())); -} - -void -convert_executor_to_slime(const SyncableThreadExecutor* executor, Cursor& object) -{ - if (executor == nullptr) { - return; - } - if (const auto* single = dynamic_cast<const SingleExecutor*>(executor)) { - convert_single_executor_to_slime(*single, object); - } else if (const auto* blocking = dynamic_cast<const BlockingThreadStackExecutor*>(executor)) { - convert_syncable_executor_to_slime(*blocking, "BlockingThreadStackExecutor", object); - } else if (const auto* thread = dynamic_cast<const ThreadStackExecutor*>(executor)) { - convert_syncable_executor_to_slime(*thread, "ThreadStackExecutor", object); - } else { - convert_syncable_executor_to_slime(*executor, "SyncableThreadExecutor", object); - } -} - -void convert_sequenced_executor_to_slime(const SequencedTaskExecutor& executor, Cursor& object) { set_type(object, "SequencedTaskExecutor"); diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index dddca6a9ddd..203b58437f3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -10,6 +10,7 @@ #include "proton.h" #include "proton_config_snapshot.h" #include "proton_disk_layout.h" +#include "proton_thread_pools_explorer.h" #include "resource_usage_explorer.h" #include "searchhandlerproxy.h" #include "simpleflush.h" @@ -836,6 +837,7 @@ const vespalib::string DOCUMENT_DB = "documentdb"; const vespalib::string FLUSH_ENGINE = "flushengine"; const vespalib::string TLS_NAME = "tls"; const vespalib::string RESOURCE_USAGE = "resourceusage"; +const vespalib::string THREAD_POOLS = "threadpools"; struct StateExplorerProxy : vespalib::StateExplorer { const StateExplorer &explorer; @@ -881,8 +883,7 @@ Proton::get_state(const vespalib::slime::Inserter &, bool) const std::vector<vespalib::string> Proton::get_children_names() const { - std::vector<vespalib::string> names({DOCUMENT_DB, MATCH_ENGINE, FLUSH_ENGINE, TLS_NAME, RESOURCE_USAGE}); - return names; + return {DOCUMENT_DB, THREAD_POOLS, MATCH_ENGINE, FLUSH_ENGINE, TLS_NAME, RESOURCE_USAGE}; } std::unique_ptr<vespalib::StateExplorer> @@ -899,6 +900,13 @@ Proton::get_child(vespalib::stringref name) const return std::make_unique<search::transactionlog::TransLogServerExplorer>(_tls->getTransLogServer()); } else if (name == RESOURCE_USAGE && _diskMemUsageSampler) { return std::make_unique<ResourceUsageExplorer>(_diskMemUsageSampler->writeFilter()); + } else if (name == THREAD_POOLS) { + return std::make_unique<ProtonThreadPoolsExplorer>(_sharedExecutor.get(), + (_matchEngine) ? &_matchEngine->get_executor() : nullptr, + (_summaryEngine) ? &_summaryEngine->get_executor() : nullptr, + (_flushEngine) ? &_flushEngine->get_executor() : nullptr, + &_executor, + _warmupExecutor.get()); } return Explorer_UP(nullptr); } diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.cpp b/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.cpp new file mode 100644 index 00000000000..e0db9e29c35 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.cpp @@ -0,0 +1,43 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "executor_explorer_utils.h" +#include "proton_thread_pools_explorer.h" +#include <vespa/vespalib/data/slime/cursor.h> +#include <vespa/vespalib/util/threadexecutor.h> + +using vespalib::SyncableThreadExecutor; + +namespace proton { + +using explorer::convert_executor_to_slime; + +ProtonThreadPoolsExplorer::ProtonThreadPoolsExplorer(const SyncableThreadExecutor* shared, + const SyncableThreadExecutor* match, + const SyncableThreadExecutor* docsum, + const SyncableThreadExecutor* flush, + const SyncableThreadExecutor* proton, + const SyncableThreadExecutor* warmup) + : _shared(shared), + _match(match), + _docsum(docsum), + _flush(flush), + _proton(proton), + _warmup(warmup) +{ +} + +void +ProtonThreadPoolsExplorer::get_state(const vespalib::slime::Inserter& inserter, bool full) const +{ + auto& object = inserter.insertObject(); + if (full) { + convert_executor_to_slime(_shared, object.setObject("shared")); + convert_executor_to_slime(_match, object.setObject("match")); + convert_executor_to_slime(_docsum, object.setObject("docsum")); + convert_executor_to_slime(_flush, object.setObject("flush")); + convert_executor_to_slime(_proton, object.setObject("proton")); + convert_executor_to_slime(_warmup, object.setObject("warmup")); + } +} + +} diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.h b/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.h new file mode 100644 index 00000000000..8022a0483c4 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.h @@ -0,0 +1,35 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <vespa/vespalib/net/state_explorer.h> + +namespace vespalib { class SyncableThreadExecutor; } + +namespace proton { + +/** + * Class used to explore the shared thread pools used by proton and it's document databases. + */ +class ProtonThreadPoolsExplorer : public vespalib::StateExplorer { +private: + const vespalib::SyncableThreadExecutor* _shared; + const vespalib::SyncableThreadExecutor* _match; + const vespalib::SyncableThreadExecutor* _docsum; + const vespalib::SyncableThreadExecutor* _flush; + const vespalib::SyncableThreadExecutor* _proton; + const vespalib::SyncableThreadExecutor* _warmup; + +public: + ProtonThreadPoolsExplorer(const vespalib::SyncableThreadExecutor* shared, + const vespalib::SyncableThreadExecutor* match, + const vespalib::SyncableThreadExecutor* docsum, + const vespalib::SyncableThreadExecutor* flush, + const vespalib::SyncableThreadExecutor* proton, + const vespalib::SyncableThreadExecutor* warmup); + + void get_state(const vespalib::slime::Inserter& inserter, bool full) const override; +}; + +} + diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h index 029aefacfc8..c1cb1f91a2a 100644 --- a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h +++ b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h @@ -65,6 +65,11 @@ public: vespalib::ThreadStackExecutor::Stats getExecutorStats() { return _executor.getStats(); } /** + * Returns the underlying executor. Only used for state explorers. + */ + const vespalib::SyncableThreadExecutor& get_executor() const { return _executor; } + + /** * Starts the underlying threads. This will throw a vespalib::Exception if * it failed to start for any reason. */ |