summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-09-01 13:42:55 +0200
committerGitHub <noreply@github.com>2016-09-01 13:42:55 +0200
commit33bbb5d4369c26eb73bdf3aac23382dbc2da75b1 (patch)
tree9cc0afc5899590fbf198951b1652136b0902ae67
parent731d72ae94e00a3df09afee0377c28c5d73fcf90 (diff)
parent2e011896231d68582f69b36943e14ebd5aa02b44 (diff)
Merge pull request #528 from yahoo/vekterli/improve-blocking-thread-mutex-acquisition-chances
Let blocked threads have an actual fair chance to be scheduled
-rw-r--r--storage/src/vespa/storage/bucketdb/lockablemap.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/storage/src/vespa/storage/bucketdb/lockablemap.h b/storage/src/vespa/storage/bucketdb/lockablemap.h
index bfc35f80f44..95d9326eff0 100644
--- a/storage/src/vespa/storage/bucketdb/lockablemap.h
+++ b/storage/src/vespa/storage/bucketdb/lockablemap.h
@@ -23,6 +23,7 @@
#include <vespa/document/bucket/bucketid.h>
#include <vespa/storage/common/bucketoperationlogger.h>
#include <thread>
+#include <chrono>
namespace storage {
@@ -671,7 +672,14 @@ LockableMap<Map>::chunkedAll(Functor& functor,
{
key_type key{};
while (processNextChunk(functor, key, clientId, chunkSize)) {
- std::this_thread::yield();
+ // Rationale: delay iteration for as short a time as possible while
+ // allowing another thread blocked on the main DB mutex to acquire it
+ // in the meantime. Simply yielding the thread does not have the
+ // intended effect with the Linux scheduler.
+ // This is a pragmatic stop-gap solution; a more robust change requires
+ // the redesign of bucket DB locking and signalling semantics in the
+ // face of blocked point lookups.
+ std::this_thread::sleep_for(std::chrono::microseconds(100));
}
}