summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2021-11-26 13:23:47 +0000
committerGeir Storli <geirst@yahooinc.com>2021-11-29 10:41:48 +0000
commit3c4983f0109da80fefc643e43d12798ccf38fb80 (patch)
tree68eeb036acbcbab3006c989df48b5fc592d29f15 /searchcore
parent20e2b4db40afbe9b1eb05109524869e0e06b84e0 (diff)
Test deriving of the number of shared threads (among all document dbs).
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/CMakeLists.txt1
-rw-r--r--searchcore/src/tests/proton/server/shared_threading_service/CMakeLists.txt9
-rw-r--r--searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp41
3 files changed, 51 insertions, 0 deletions
diff --git a/searchcore/CMakeLists.txt b/searchcore/CMakeLists.txt
index e08b951d3f3..c63ccfe4e24 100644
--- a/searchcore/CMakeLists.txt
+++ b/searchcore/CMakeLists.txt
@@ -154,6 +154,7 @@ vespa_define_module(
src/tests/proton/server/health_adapter
src/tests/proton/server/memory_flush_config_updater
src/tests/proton/server/memoryflush
+ src/tests/proton/server/shared_threading_service
src/tests/proton/statusreport
src/tests/proton/summaryengine
src/tests/proton/verify_ranksetup
diff --git a/searchcore/src/tests/proton/server/shared_threading_service/CMakeLists.txt b/searchcore/src/tests/proton/server/shared_threading_service/CMakeLists.txt
new file mode 100644
index 00000000000..9b40ae19c99
--- /dev/null
+++ b/searchcore/src/tests/proton/server/shared_threading_service/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(searchcore_shared_threading_service_test_app TEST
+ SOURCES
+ shared_threading_service_test.cpp
+ DEPENDS
+ searchcore_server
+ GTest::GTest
+)
+vespa_add_test(NAME searchcore_shared_threading_service_test_app COMMAND searchcore_shared_threading_service_test_app)
diff --git a/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp b/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp
new file mode 100644
index 00000000000..faf64af17e1
--- /dev/null
+++ b/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp
@@ -0,0 +1,41 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <vespa/searchcore/config/config-proton.h>
+#include <vespa/searchcore/proton/server/shared_threading_service_config.h>
+#include <vespa/vespalib/gtest/gtest.h>
+
+using namespace proton;
+using ProtonConfig = vespa::config::search::core::ProtonConfig;
+using ProtonConfigBuilder = vespa::config::search::core::ProtonConfigBuilder;
+
+ProtonConfig
+make_proton_config(double concurrency)
+{
+ ProtonConfigBuilder builder;
+ // This setup requires a minimum of 4 shared threads.
+ builder.documentdb.push_back(ProtonConfig::Documentdb());
+ builder.documentdb.push_back(ProtonConfig::Documentdb());
+ builder.flush.maxconcurrent = 1;
+
+ builder.feeding.concurrency = concurrency;
+ return builder;
+}
+
+void
+expect_shared_threads(uint32_t exp_threads, uint32_t cpu_cores)
+{
+ auto cfg = SharedThreadingServiceConfig::make(make_proton_config(0.5), HwInfo::Cpu(cpu_cores));
+ EXPECT_EQ(exp_threads, cfg.shared_threads());
+ EXPECT_EQ(exp_threads * 16, cfg.shared_task_limit());
+}
+
+TEST(SharedThreadingServiceConfigTest, shared_threads_are_derived_from_cpu_cores_and_feeding_concurrency)
+{
+ expect_shared_threads(4, 1);
+ expect_shared_threads(4, 6);
+ expect_shared_threads(4, 8);
+ expect_shared_threads(5, 9);
+ expect_shared_threads(5, 10);
+}
+
+GTEST_MAIN_RUN_ALL_TESTS()