crimson/os/alienstore: improve alienstore's write parallelism

replace the grand per store tp_mutex with a finer grained per-collection
lock for better concurrency

Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
This commit is contained in:
Xuehan Xu 2021-02-25 16:57:23 +08:00
parent 731c20fe49
commit 14d046fd66
3 changed files with 8 additions and 3 deletions

View File

@ -19,8 +19,14 @@ public:
~AlienCollection() {}
template <typename Func, typename Result = std::invoke_result_t<Func>>
seastar::futurize_t<Result> with_lock(Func&& func) {
return seastar::with_lock(mutex, std::forward<Func>(func));
}
private:
ObjectStore::CollectionHandle collection;
seastar::shared_mutex mutex;
friend AlienStore;
};
}

View File

@ -363,7 +363,8 @@ seastar::future<> AlienStore::do_transaction(CollectionRef ch,
std::move(done),
[this, ch, id] (auto &txn, auto &done) {
return seastar::with_gate(transaction_gate, [this, ch, id, &txn, &done] {
return tp_mutex.lock().then ([this, ch, id, &txn, &done] {
AlienCollection* alien_coll = static_cast<AlienCollection*>(ch.get());
return alien_coll->with_lock([this, ch, id, &txn, &done] {
Context *crimson_wrapper =
ceph::os::Transaction::collect_all_contexts(txn);
return tp->submit([this, ch, id, crimson_wrapper, &txn, &done] {
@ -373,7 +374,6 @@ seastar::future<> AlienStore::do_transaction(CollectionRef ch,
});
}).then([this, &done] (int r) {
assert(r == 0);
tp_mutex.unlock();
return done.get_future();
});
});

View File

@ -120,6 +120,5 @@ private:
std::unique_ptr<CephContext> cct;
seastar::gate transaction_gate;
std::unordered_map<coll_t, CollectionRef> coll_map;
seastar::shared_mutex tp_mutex;
};
}