From a242076ecc45fe6e3b82ea61c4b0302f4dc1ef24 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Tue, 5 Jul 2016 23:02:59 -0700 Subject: [PATCH] Performance improvement: Allow more parallelity when getting read()/write() syscalls to the same blob --- .../implementations/onblocks/datatreestore/DataTree.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp b/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp index 682ff062..e74e4edd 100644 --- a/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp +++ b/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp @@ -159,7 +159,8 @@ uint32_t DataTree::_numLeaves(const DataNode &node) const { void DataTree::traverseLeaves(uint32_t beginIndex, uint32_t endIndex, function func) { //TODO Can we traverse in parallel? - unique_lock lock(_mutex); //TODO Only lock when resizing. Otherwise parallel read/write to a blob is not possible! + boost::upgrade_lock lock(_mutex); //TODO Rethink locking here. We probably need locking when the traverse resizes the blob. Otherwise, parallel traverse should be possible. We already allow it below by freeing the upgrade_lock, but we currently only allow it if ALL traverses are entirely inside the valid region. Can we allow more parallelity? + auto exclusiveLock = std::make_unique>(lock); ASSERT(beginIndex <= endIndex, "Invalid parameters"); if (0 == endIndex) { // In this case the utils::ceilLog(_, endIndex) below would fail @@ -195,6 +196,7 @@ void DataTree::traverseLeaves(uint32_t beginIndex, uint32_t endIndex, function