summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2020-05-19 14:22:00 +0000
committerHåvard Pettersen <havardpe@oath.com>2020-05-19 14:49:30 +0000
commitcdee9f2f3471fa018eadde13e1300a882a327460 (patch)
treed9211f923e210456abbb461a680934dda3467fe1
parent89e26b2fe42a1fd88957ec76c5e1d1532d03b380 (diff)
let compile cache use shared proton executor
-rw-r--r--eval/src/tests/eval/compile_cache/compile_cache_test.cpp3
-rw-r--r--eval/src/vespa/eval/eval/llvm/compile_cache.cpp21
-rw-r--r--eval/src/vespa/eval/eval/llvm/compile_cache.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.cpp3
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp2
6 files changed, 31 insertions, 1 deletions
diff --git a/eval/src/tests/eval/compile_cache/compile_cache_test.cpp b/eval/src/tests/eval/compile_cache/compile_cache_test.cpp
index 5176a4b3e94..1de56e605c9 100644
--- a/eval/src/tests/eval/compile_cache/compile_cache_test.cpp
+++ b/eval/src/tests/eval/compile_cache/compile_cache_test.cpp
@@ -275,6 +275,7 @@ TEST_F("compile sequentially, then run all conformance tests", test::EvalSpec())
auto t0 = steady_clock::now();
f1.each_case(test);
auto t1 = steady_clock::now();
+ CompileCache::wait_pending();
auto t2 = steady_clock::now();
test.verify();
auto t3 = steady_clock::now();
@@ -295,7 +296,7 @@ TEST_F("compile concurrently (8 threads), then run all conformance tests", test:
auto t0 = steady_clock::now();
f1.each_case(test);
auto t1 = steady_clock::now();
- executor.sync();
+ CompileCache::wait_pending();
auto t2 = steady_clock::now();
test.verify();
auto t3 = steady_clock::now();
diff --git a/eval/src/vespa/eval/eval/llvm/compile_cache.cpp b/eval/src/vespa/eval/eval/llvm/compile_cache.cpp
index 9a262f6dca5..4aa18d3bb65 100644
--- a/eval/src/vespa/eval/eval/llvm/compile_cache.cpp
+++ b/eval/src/vespa/eval/eval/llvm/compile_cache.cpp
@@ -77,6 +77,27 @@ CompileCache::compile(const Function &function, PassParams pass_params)
return token;
}
+void
+CompileCache::wait_pending()
+{
+ std::vector<Token::UP> pending;
+ {
+ std::lock_guard<std::mutex> guard(_lock);
+ for (auto entry = _cached.begin(); entry != _cached.end(); ++entry) {
+ if (entry->second.compiled_function.get() == nullptr) {
+ ++(entry->second.num_refs);
+ pending.push_back(std::make_unique<Token>(entry, Token::ctor_tag()));
+ }
+ }
+ }
+ {
+ for (const auto &token: pending) {
+ const CompiledFunction &fun = token->get();
+ (void) fun;
+ }
+ }
+}
+
size_t
CompileCache::num_cached()
{
diff --git a/eval/src/vespa/eval/eval/llvm/compile_cache.h b/eval/src/vespa/eval/eval/llvm/compile_cache.h
index aaadec772a5..09b5b2060f5 100644
--- a/eval/src/vespa/eval/eval/llvm/compile_cache.h
+++ b/eval/src/vespa/eval/eval/llvm/compile_cache.h
@@ -84,6 +84,7 @@ public:
};
static Token::UP compile(const Function &function, PassParams pass_params);
+ static void wait_pending();
static ExecutorBinding::UP bind(Executor &executor) {
return std::make_unique<ExecutorBinding>(executor, ExecutorBinding::ctor_tag());
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
index c7000119861..719ba359ccf 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
@@ -212,6 +212,7 @@ Proton::Proton(const config::ConfigUri & configUri,
_protonConfigFetcher(configUri, _protonConfigurer, subscribeTimeout),
_warmupExecutor(),
_sharedExecutor(),
+ _compile_cache_executor_binding(),
_queryLimiter(),
_clock(0.001),
_threadPool(128 * 1024),
@@ -302,6 +303,7 @@ Proton::init(const BootstrapConfig::SP & configSnapshot)
const size_t sharedThreads = deriveCompactionCompressionThreads(protonConfig, hwInfo.cpu());
_sharedExecutor = std::make_unique<vespalib::BlockingThreadStackExecutor>(sharedThreads, 128*1024, sharedThreads*16, proton_shared_executor);
+ _compile_cache_executor_binding = vespalib::eval::CompileCache::bind(*_sharedExecutor);
InitializeThreads initializeThreads;
if (protonConfig.initialize.threads > 0) {
initializeThreads = std::make_shared<vespalib::ThreadStackExecutor>(protonConfig.initialize.threads, 128 * 1024, initialize_executor);
@@ -454,6 +456,7 @@ Proton::~Proton()
_persistenceEngine.reset();
_tls.reset();
_warmupExecutor.reset();
+ _compile_cache_executor_binding.reset();
_sharedExecutor.reset();
_clock.stop();
LOG(debug, "Explicit destructor done");
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h
index 4c9d4c77cc4..d0b76bd5804 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.h
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.h
@@ -26,6 +26,7 @@
#include <vespa/vespalib/net/json_handler_repo.h>
#include <vespa/vespalib/net/state_explorer.h>
#include <vespa/vespalib/util/varholder.h>
+#include <vespa/eval/eval/llvm/compile_cache.h>
#include <mutex>
#include <shared_mutex>
@@ -112,6 +113,7 @@ private:
ProtonConfigFetcher _protonConfigFetcher;
std::unique_ptr<vespalib::ThreadStackExecutorBase> _warmupExecutor;
std::unique_ptr<vespalib::ThreadStackExecutorBase> _sharedExecutor;
+ vespalib::eval::CompileCache::ExecutorBinding::UP _compile_cache_executor_binding;
matching::QueryLimiter _queryLimiter;
vespalib::Clock _clock;
FastOS_ThreadPool _threadPool;
diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp
index 9ef038b7325..c4a0ac5e099 100644
--- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp
@@ -9,6 +9,7 @@
#include <vespa/searchcore/proton/common/indexschema_inspector.h>
#include <vespa/searchcore/proton/reference/i_document_db_reference_resolver.h>
#include <vespa/searchcore/proton/reprocessing/attribute_reprocessing_initializer.h>
+#include <vespa/eval/eval/llvm/compile_cache.h>
using namespace vespa::config::search;
using namespace config;
@@ -87,6 +88,7 @@ void
SearchableDocSubDBConfigurer::reconfigureSearchView(MatchView::SP matchView)
{
SearchView::SP curr = _searchView.get();
+ vespalib::eval::CompileCache::wait_pending();
_searchView.set(SearchView::create(curr->getSummarySetup(), std::move(matchView)));
}