Skip to content

Commit 44eb93c

Browse files
authored
v5.x - Remove more dependence on Facebook Folly. (#147)
* v5.x - Remove more dependence on Facebook Folly. Remove usage of folly::Expected and folly::Unit in the API. folly::Future remains.
1 parent 6ca1f82 commit 44eb93c

File tree

12 files changed

+100
-151
lines changed

12 files changed

+100
-151
lines changed

.github/workflows/build_dependencies.yml

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -153,80 +153,27 @@ jobs:
153153
conan export --user oss --channel main import/nuraft_mesg
154154
if: ${{ inputs.testing == 'True' || steps.restore-cache.outputs.cache-hit != 'true' }}
155155

156-
- name: Build Cache
156+
- name: Create and Test Package
157157
run: |
158-
conan install \
159-
-c tools.build:skip_test=True \
158+
sanitize=$([[ "${{ inputs.tooling }}" == "Sanitize" ]] && echo "True" || echo "False")
159+
conan build \
160160
-o sisl/*:malloc_impl=${{ inputs.malloc-impl }} \
161161
-o iomgr/*:testing=off \
162162
-o homestore/*:testing=off \
163+
-o homeblocks/*:sanitize=${sanitize} \
163164
-s:h build_type=${{ inputs.build-type }} \
164-
-c tools.build:skip_test=True \
165+
-s:h compiler.cppstd=23 \
165166
--format=json \
166167
--build missing \
167168
. > ~/build.json
168169
conan list --graph ~/build.json --graph-binaries=build --format=json > ~/pkglist.json
169-
if: ${{ steps.restore-cache.outputs.cache-hit != 'true' }}
170+
if: ${{ inputs.testing == 'True' && inputs.tooling != 'Coverage' }}
170171

171172
- name: Save Conan Cache
172173
uses: eBay/sisl/.github/actions/store_conan2@master
173174
with:
174175
key_prefix: HomeBlocksDeps-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}
175-
if: ${{ github.event_name != 'pull_request' && steps.restore-cache.outputs.cache-hit != 'true' }}
176-
177-
- name: Reload Sisl Cache
178-
uses: eBay/sisl/.github/actions/load_conan2@master
179-
with:
180-
load_any: 'True'
181-
key_prefix: SislDeps13-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}
182-
if: ${{ inputs.testing == 'True' && github.event_name != 'pull_request' && steps.restore-cache.outputs.cache-hit != 'true' }}
183-
184-
- name: Reload IOMgr Cache
185-
uses: eBay/sisl/.github/actions/load_conan2@master
186-
with:
187-
load_any: 'True'
188-
key_prefix: IOMgrDeps-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}-False
189-
if: ${{ inputs.testing == 'True' && github.event_name != 'pull_request' && steps.restore-cache.outputs.cache-hit != 'true' }}
190-
191-
- name: Reload NuRaftMesg Cache
192-
uses: eBay/sisl/.github/actions/load_conan2@master
193-
with:
194-
testing: 'False'
195-
path: import/nuraft_mesg
196-
key_prefix: NuMesgDeps-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}
197-
fail_on_cache_miss: true
198-
if: ${{ inputs.testing == 'True' && github.event_name != 'pull_request' && steps.restore-cache.outputs.cache-hit != 'true' }}
199-
200-
- name: Reload HomeStore Cache
201-
uses: eBay/sisl/.github/actions/load_conan2@master
202-
with:
203-
testing: 'False'
204-
path: import/homestore
205-
key_prefix: HomestoreDeps-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}-False
206-
fail_on_cache_miss: true
207-
if: ${{ inputs.testing == 'True' && github.event_name != 'pull_request' && steps.restore-cache.outputs.cache-hit != 'true' }}
208-
209-
- uses: actions/checkout@main
210-
- name: Setup tmate session
211-
uses: mxschmitt/action-tmate@v3
212-
with:
213-
limit-access-to-actor: true
214-
detached: true
215-
connect-timeout-seconds: 60
216-
if: ${{ inputs.testing == 'True' }}
217-
218-
- name: Create and Test Package
219-
run: |
220-
sanitize=$([[ "${{ inputs.tooling }}" == "Sanitize" ]] && echo "True" || echo "False")
221-
conan create \
222-
-o sisl/*:malloc_impl=${{ inputs.malloc-impl }} \
223-
-o iomgr/*:testing=off \
224-
-o homestore/*:testing=off \
225-
-o homeblocks/*:sanitize=${sanitize} \
226-
-s:h build_type=${{ inputs.build-type }} \
227-
--build missing \
228-
.
229-
if: ${{ inputs.testing == 'True' && inputs.tooling != 'Coverage' }}
176+
if: ${{ github.event_name != 'pull_request' && steps.restore-cache.outputs.cache-hit != 'true' && inputs.tooling != 'Coverage'}}
230177

231178
- name: Code Coverage Run
232179
run: |
@@ -236,6 +183,7 @@ jobs:
236183
-o homestore/*:testing=off \
237184
-o homeblocks/*:coverage=True \
238185
-s:h build_type=${{ inputs.build-type }} \
186+
-s:h compiler.cppstd=23 \
239187
--build missing \
240188
.
241189
if: ${{ inputs.testing == 'True' && inputs.tooling == 'Coverage' }}

.jenkins/Jenkinsfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ pipeline {
5959

6060
stage("Compile") {
6161
steps {
62-
sh "conan create ${BUILD_MISSING} -s:h build_type=Debug -o ${PROJECT}/*:sanitize=True ${CONAN_FLAGS} . ; \
63-
conan create ${BUILD_MISSING} -s:h build_type=Debug ${CONAN_FLAGS} . ; \
64-
conan create ${BUILD_MISSING} -s:h build_type=RelWithDebInfo -o sisl/*:malloc_impl=tcmalloc ${CONAN_FLAGS} . ; \
62+
sh "conan build -s:h compiler.cppstd=23 ${BUILD_MISSING} -s:h build_type=Debug -o ${PROJECT}/*:sanitize=True ${CONAN_FLAGS} . ; \
63+
conan create -s:h compiler.cppstd=23 ${BUILD_MISSING} -s:h build_type=Debug ${CONAN_FLAGS} . ; \
64+
conan create -s:h compiler.cppstd=23 ${BUILD_MISSING} -s:h build_type=RelWithDebInfo -o sisl/*:malloc_impl=tcmalloc ${CONAN_FLAGS} . ; \
6565
"
6666
}
6767
}

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required (VERSION 3.11)
22
project (homeblocks LANGUAGES CXX)
33

4-
set(CMAKE_CXX_STANDARD 20)
4+
set(CMAKE_CXX_STANDARD 23)
55

66
if (NOT DEFINED CMAKE_BUILD_TYPE)
77
set (CMAKE_BUILD_TYPE "Debug")

conanfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class HomeBlocksConan(ConanFile):
1111
name = "homeblocks"
12-
version = "4.0.1"
12+
version = "5.0.0"
1313

1414
homepage = "https://github.com/eBay/HomeBlocks"
1515
description = "Block Store built on HomeStore"
@@ -52,7 +52,7 @@ def requirements(self):
5252

5353
def validate(self):
5454
if self.info.settings.compiler.cppstd:
55-
check_min_cppstd(self, 20)
55+
check_min_cppstd(self, 23)
5656

5757
def layout(self):
5858
self.folders.source = "."

src/include/homeblks/common.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
*********************************************************************************/
1616
#pragma once
1717

18+
#include <expected>
19+
1820
#include <boost/uuid/uuid.hpp>
1921
#include <boost/intrusive_ptr.hpp>
20-
#include <folly/Expected.h>
21-
#include <folly/Unit.h>
2222
#pragma GCC diagnostic push
2323
#pragma GCC diagnostic ignored "-Wuninitialized"
2424
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
@@ -74,12 +74,12 @@ template < class E >
7474
class Manager {
7575
public:
7676
template < typename T >
77-
using Result = folly::Expected< T, E >;
77+
using Result = std::expected< T, E >;
7878
template < typename T >
7979
using AsyncResult = folly::Future< Result< T > >;
8080

81-
using NullResult = Result< folly::Unit >;
82-
using NullAsyncResult = AsyncResult< folly::Unit >;
81+
using NullResult = Result< void >;
82+
using NullAsyncResult = AsyncResult< void >;
8383

8484
virtual ~Manager() = default;
8585
};

src/include/homeblks/volume_mgr.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ struct vol_interface_req : public sisl::ObjLifeCounter< vol_interface_req > {
3030
VolumePtr vol{nullptr}; // back ref to the volume this request is associated with.
3131
Clock::time_point io_start_time; // time when the request reaches homeblks.
3232
Clock::time_point data_svc_start_time; // time when the request to data service starts.
33-
Clock::time_point index_start_time; // time when the request to index service starts.
34-
Clock::time_point journal_start_time; // time when the request to journal service starts.
33+
Clock::time_point index_start_time; // time when the request to index service starts.
34+
Clock::time_point journal_start_time; // time when the request to journal service starts.
3535

3636
friend void intrusive_ptr_add_ref(vol_interface_req* req) { req->refcount.increment(1); }
3737
friend void intrusive_ptr_release(vol_interface_req* req);

src/lib/volume/index_fixed_table.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,21 @@ class VolumeIndexTable {
6767
LOGERROR("Failed to put to index {}, error={}", lba, result);
6868
// rollback the lbas for which we have already written to the index table
6969
rollback_write(start_lba, lba - 1, blocks_info);
70-
return folly::makeUnexpected(VolumeError::INDEX_ERROR);
70+
return std::unexpected(VolumeError::INDEX_ERROR);
7171
}
7272
}
7373

7474
return folly::Unit();
7575
}
7676

77-
VolumeManager::Result< folly::Unit > read_from_index(const vol_interface_req_ptr& req, index_kv_list_t& index_kvs) {
77+
VolumeManager::NullResult read_from_index(const vol_interface_req_ptr& req, index_kv_list_t& index_kvs) {
7878
homestore::BtreeQueryRequest< VolumeIndexKey > qreq{
7979
homestore::BtreeKeyRange< VolumeIndexKey >{VolumeIndexKey{req->lba}, VolumeIndexKey{req->end_lba()}},
8080
homestore::BtreeQueryType::SWEEP_NON_INTRUSIVE_PAGINATION_QUERY};
8181
if (auto ret = hs_index_table_->query(qreq, index_kvs); ret != homestore::btree_status_t::success) {
82-
return folly::makeUnexpected(VolumeError::INDEX_ERROR);
82+
return std::unexpected(VolumeError::INDEX_ERROR);
8383
}
84-
return folly::Unit();
84+
return {};
8585
}
8686

8787
void rollback_write(lba_t start_lba, lba_t end_lba, std::unordered_map< lba_t, BlockInfo >& blocks_info) {
@@ -110,4 +110,4 @@ class VolumeIndexTable {
110110
}
111111
};
112112

113-
} // namespace homeblocks
113+
} // namespace homeblocks

src/lib/volume/index_prefix_table.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class VolumeIndexTable {
4848
auto result = hs_index_table_->put(req);
4949
if (result != homestore::btree_status_t::success) {
5050
LOGERROR("Failed to put to index range=({},{}) error={}", start_lba, end_lba, result);
51-
return folly::makeUnexpected(VolumeError::INDEX_ERROR);
51+
return std::unexpected(VolumeError::INDEX_ERROR);
5252
}
5353

5454
return folly::Unit();
@@ -59,7 +59,7 @@ class VolumeIndexTable {
5959
homestore::BtreeKeyRange< VolumeIndexKey >{VolumeIndexKey{req->lba}, VolumeIndexKey{req->end_lba()}},
6060
homestore::BtreeQueryType::SWEEP_NON_INTRUSIVE_PAGINATION_QUERY};
6161
if (auto ret = hs_index_table_->query(qreq, index_kvs); ret != homestore::btree_status_t::success) {
62-
return folly::makeUnexpected(VolumeError::INDEX_ERROR);
62+
return std::unexpected(VolumeError::INDEX_ERROR);
6363
}
6464
return folly::Unit();
6565
}
@@ -70,4 +70,4 @@ class VolumeIndexTable {
7070
}
7171
};
7272

73-
} // namespace homeblocks
73+
} // namespace homeblocks

src/lib/volume/tests/test_volume_io.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class VolumeIOImpl {
207207
vol_mgr->write(m_vol_ptr, req)
208208
.via(&folly::InlineExecutor::instance())
209209
.thenValue([this, data, req, latch, expect_failure](auto&& result) {
210-
ASSERT_EQ(result.hasError(), expect_failure);
210+
ASSERT_EQ(!result.has_value(), expect_failure);
211211
{
212212
std::lock_guard lock(m_mutex);
213213
m_inflight_ios.erase(boost::icl::interval< int >::closed(req->lba, req->lba + req->nlbas - 1));
@@ -245,7 +245,7 @@ class VolumeIOImpl {
245245
vol_mgr->write(m_vol_ptr, req)
246246
.via(&folly::InlineExecutor::instance())
247247
.thenValue([this, req, data](auto&& result) {
248-
RELEASE_ASSERT(!result.hasError(), "Write failed with error={}", result.error());
248+
RELEASE_ASSERT(result.has_value(), "Write failed with error={}", result.error());
249249
{
250250
std::lock_guard lock(m_mutex);
251251
m_inflight_ios.erase(boost::icl::interval< int >::closed(req->lba, req->lba + req->nlbas - 1));
@@ -262,8 +262,8 @@ class VolumeIOImpl {
262262
auto buf = read_blob.bytes();
263263
vol_interface_req_ptr req(new vol_interface_req{buf, start_lba, nlbas, m_vol_ptr});
264264
auto read_resp = g_helper->inst()->volume_manager()->read(m_vol_ptr, req).get();
265-
if (read_resp.hasError()) { LOGERROR("Read failed with error={}", read_resp.error()); }
266-
RELEASE_ASSERT(!read_resp.hasError(), "Read failed with error={}", read_resp.error());
265+
if (!read_resp.has_value()) { LOGERROR("Read failed with error={}", read_resp.error()); }
266+
RELEASE_ASSERT(read_resp.has_value(), "Read failed with error={}", read_resp.error());
267267
}
268268

269269
void read_and_verify(lba_t start_lba, uint32_t nlbas) {
@@ -273,8 +273,8 @@ class VolumeIOImpl {
273273
auto buf = read_blob.bytes();
274274
vol_interface_req_ptr req(new vol_interface_req{buf, start_lba, nlbas, m_vol_ptr});
275275
auto read_resp = g_helper->inst()->volume_manager()->read(m_vol_ptr, req).get();
276-
if (read_resp.hasError()) { LOGERROR("Read failed with error={}", read_resp.error()); }
277-
RELEASE_ASSERT(!read_resp.hasError(), "Read failed with error={}", read_resp.error());
276+
if (!read_resp.has_value()) { LOGERROR("Read failed with error={}", read_resp.error()); }
277+
RELEASE_ASSERT(read_resp.has_value(), "Read failed with error={}", read_resp.error());
278278
auto read_sz = m_vol_ptr->info()->page_size;
279279
for (auto lba = start_lba; lba < start_lba + nlbas; lba++, buf += read_sz) {
280280
uint64_t data_pattern = 0;
@@ -305,7 +305,7 @@ class VolumeIOImpl {
305305
->read(m_vol_ptr, req)
306306
.via(&folly::InlineExecutor::instance())
307307
.thenValue([this, read_blob = std::move(read_blob), req](auto&& result) {
308-
RELEASE_ASSERT(!result.hasError(), "Read failed with error={}", result.error());
308+
RELEASE_ASSERT(result.has_value(), "Read failed with error={}", result.error());
309309
{
310310
std::lock_guard lock(m_mutex);
311311
m_inflight_ios.erase(boost::icl::interval< int >::closed(req->lba, req->lba + req->nlbas - 1));

0 commit comments

Comments
 (0)