Skip to content

Commit acfa761

Browse files
committed
implement gc thread model
1 parent f0c177e commit acfa761

17 files changed

+1130
-116
lines changed

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class HomeObjectConan(ConanFile):
1111
name = "homeobject"
12-
version = "2.3.17"
12+
version = "2.3.20"
1313

1414
homepage = "https://github.com/eBay/HomeObject"
1515
description = "Blob Store built on HomeReplication"

src/lib/blob_route.hpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <boost/functional/hash.hpp>
77

8-
#include "homeobject/common.hpp"
8+
#include "homeobject_impl.hpp"
99

1010
namespace homeobject {
1111

@@ -19,11 +19,37 @@ struct BlobRoute {
1919
auto operator<=>(BlobRoute const&) const = default;
2020
sisl::blob to_blob() const { return sisl::blob{uintptr_cast(const_cast< BlobRoute* >(this)), sizeof(*this)}; }
2121
};
22+
23+
// used for gc to quickly identify all the blob in the move_to chunk
24+
struct BlobRouteByChunk {
25+
// homestore::chunk_num_t == uint16_t
26+
uint16_t chunk;
27+
shard_id_t shard;
28+
blob_id_t blob;
29+
auto operator<=>(BlobRouteByChunk const&) const = default;
30+
sisl::blob to_blob() const {
31+
return sisl::blob{uintptr_cast(const_cast< BlobRouteByChunk* >(this)), sizeof(*this)};
32+
}
33+
};
2234
#pragma pack()
2335

2436
} // namespace homeobject
2537

2638
namespace fmt {
39+
template <>
40+
struct formatter< homeobject::BlobRouteByChunk > {
41+
template < typename ParseContext >
42+
constexpr auto parse(ParseContext& ctx) {
43+
return ctx.begin();
44+
}
45+
46+
template < typename FormatContext >
47+
auto format(homeobject::BlobRouteByChunk const& r, FormatContext& ctx) {
48+
return format_to(ctx.out(), "{:04x}:{:04x}:{:012x}:{:016x}", r.chunk, (r.shard >> homeobject::shard_width),
49+
(r.shard & homeobject::shard_mask), r.blob);
50+
}
51+
};
52+
2753
template <>
2854
struct formatter< homeobject::BlobRoute > {
2955
template < typename ParseContext >
@@ -37,6 +63,7 @@ struct formatter< homeobject::BlobRoute > {
3763
(r.shard & homeobject::shard_mask), r.blob);
3864
}
3965
};
66+
4067
} // namespace fmt
4168

4269
template <>
@@ -45,3 +72,10 @@ struct std::hash< homeobject::BlobRoute > {
4572
return boost::hash_value< homeobject::blob_id_t >(std::make_pair(r.shard, r.blob));
4673
}
4774
};
75+
76+
template <>
77+
struct std::hash< homeobject::BlobRouteByChunk > {
78+
std::size_t operator()(homeobject::BlobRouteByChunk const& r) const noexcept {
79+
return boost::hash_value< homeobject::blob_id_t >(std::make_pair(r.shard, r.blob));
80+
}
81+
};

src/lib/homestore_backend/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ target_sources("${PROJECT_NAME}_homestore" PRIVATE
2929
replication_state_machine.cpp
3030
hs_cp_callbacks.cpp
3131
hs_http_manager.cpp
32+
gc_manager.cpp
3233
$<TARGET_OBJECTS:${PROJECT_NAME}_core>
3334
)
3435
target_link_libraries("${PROJECT_NAME}_homestore" PUBLIC
@@ -114,3 +115,11 @@ add_test(NAME HomestoreResyncTestWithLeaderRestart
114115
--override_config homestore_config.generic.repl_dev_cleanup_interval_sec=5
115116
--override_config homestore_config.consensus.max_grpc_message_size:138412032
116117
--gtest_filter=HomeObjectFixture.RestartLeader*)
118+
119+
add_executable(homestore_test_gc)
120+
target_sources(homestore_test_gc PRIVATE $<TARGET_OBJECTS:homestore_tests_gc>)
121+
target_link_libraries(homestore_test_gc PUBLIC homeobject_homestore ${COMMON_TEST_DEPS})
122+
add_test(NAME HomestoreTestGC COMMAND homestore_test_pg -csv error --executor immediate --config_path ./
123+
--override_config homestore_config.consensus.snapshot_freq_distance:0
124+
--override_config homestore_config.consensus.max_grpc_message_size:138412032)
125+

0 commit comments

Comments
 (0)