aboutsummaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-06-13 19:03:56 +0200
committerGitHub <noreply@github.com>2020-06-13 19:03:56 +0200
commitaacb857c63b9932ecac330d65bdd28d05d458b62 (patch)
tree41647fd58c35bc3632c0e32c5f6be396d4dc3997 /eval
parent24a8b542e20c8758f2d5973fc21e979b80247dae (diff)
parent9b52a7496663f66cbb1310ee7ebbd931ce2e04a8 (diff)
Merge pull request #13577 from vespa-engine/havardpe/separate-result-locks-for-compile-cache
use separate locks for result value propagation
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/eval/llvm/compile_cache.cpp8
-rw-r--r--eval/src/vespa/eval/eval/llvm/compile_cache.h3
2 files changed, 6 insertions, 5 deletions
diff --git a/eval/src/vespa/eval/eval/llvm/compile_cache.cpp b/eval/src/vespa/eval/eval/llvm/compile_cache.cpp
index 4aa18d3bb65..41106651024 100644
--- a/eval/src/vespa/eval/eval/llvm/compile_cache.cpp
+++ b/eval/src/vespa/eval/eval/llvm/compile_cache.cpp
@@ -15,7 +15,7 @@ std::vector<std::pair<uint64_t,Executor*>> CompileCache::_executor_stack{};
const CompiledFunction &
CompileCache::Value::wait_for_result()
{
- std::unique_lock<std::mutex> guard(_lock);
+ std::unique_lock<std::mutex> guard(result_lock);
cond.wait(guard, [this](){ return bool(compiled_function); });
return *compiled_function;
}
@@ -84,7 +84,7 @@ CompileCache::wait_pending()
{
std::lock_guard<std::mutex> guard(_lock);
for (auto entry = _cached.begin(); entry != _cached.end(); ++entry) {
- if (entry->second.compiled_function.get() == nullptr) {
+ if (entry->second.cf.load(std::memory_order_acquire) == nullptr) {
++(entry->second.num_refs);
pending.push_back(std::make_unique<Token>(entry, Token::ctor_tag()));
}
@@ -129,7 +129,7 @@ CompileCache::count_pending()
std::lock_guard<std::mutex> guard(_lock);
size_t pending = 0;
for (const auto &entry: _cached) {
- if (entry.second.compiled_function.get() == nullptr) {
+ if (entry.second.cf.load(std::memory_order_acquire) == nullptr) {
++pending;
}
}
@@ -141,7 +141,7 @@ CompileCache::CompileTask::run()
{
auto &entry = token->_entry->second;
auto result = std::make_unique<CompiledFunction>(*function, pass_params);
- std::lock_guard<std::mutex> guard(_lock);
+ std::lock_guard<std::mutex> guard(entry.result_lock);
entry.compiled_function = std::move(result);
entry.cf.store(entry.compiled_function.get(), std::memory_order_release);
entry.cond.notify_all();
diff --git a/eval/src/vespa/eval/eval/llvm/compile_cache.h b/eval/src/vespa/eval/eval/llvm/compile_cache.h
index 09b5b2060f5..e8f87e454d3 100644
--- a/eval/src/vespa/eval/eval/llvm/compile_cache.h
+++ b/eval/src/vespa/eval/eval/llvm/compile_cache.h
@@ -26,10 +26,11 @@ private:
struct Value {
size_t num_refs;
std::atomic<const CompiledFunction *> cf;
+ std::mutex result_lock;
std::condition_variable cond;
CompiledFunction::UP compiled_function;
struct ctor_tag {};
- Value(ctor_tag) : num_refs(1), cf(nullptr), cond(), compiled_function() {}
+ Value(ctor_tag) : num_refs(1), cf(nullptr), result_lock(), cond(), compiled_function() {}
const CompiledFunction &wait_for_result();
const CompiledFunction &get() {
const CompiledFunction *ptr = cf.load(std::memory_order_acquire);