Skip to content

implement gc thread model #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class HomeObjectConan(ConanFile):
name = "homeobject"
version = "2.3.19"
version = "2.3.20"

homepage = "https://github.com/eBay/HomeObject"
description = "Blob Store built on HomeReplication"
Expand Down
36 changes: 35 additions & 1 deletion src/lib/blob_route.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <boost/functional/hash.hpp>

#include "homeobject/common.hpp"
#include "homeobject_impl.hpp"

namespace homeobject {

Expand All @@ -19,11 +19,37 @@ struct BlobRoute {
auto operator<=>(BlobRoute const&) const = default;
sisl::blob to_blob() const { return sisl::blob{uintptr_cast(const_cast< BlobRoute* >(this)), sizeof(*this)}; }
};

// used for gc to quickly identify all the blob in the move_to chunk
struct BlobRouteByChunk {
// homestore::chunk_num_t == uint16_t
uint16_t chunk;
shard_id_t shard;
blob_id_t blob;
auto operator<=>(BlobRouteByChunk const&) const = default;
sisl::blob to_blob() const {
return sisl::blob{uintptr_cast(const_cast< BlobRouteByChunk* >(this)), sizeof(*this)};
}
};
#pragma pack()

} // namespace homeobject

namespace fmt {
template <>
struct formatter< homeobject::BlobRouteByChunk > {
template < typename ParseContext >
constexpr auto parse(ParseContext& ctx) {
return ctx.begin();
}

template < typename FormatContext >
auto format(homeobject::BlobRouteByChunk const& r, FormatContext& ctx) {
return format_to(ctx.out(), "{:04x}:{:04x}:{:012x}:{:016x}", r.chunk, (r.shard >> homeobject::shard_width),
(r.shard & homeobject::shard_mask), r.blob);
}
};

template <>
struct formatter< homeobject::BlobRoute > {
template < typename ParseContext >
Expand All @@ -37,6 +63,7 @@ struct formatter< homeobject::BlobRoute > {
(r.shard & homeobject::shard_mask), r.blob);
}
};

} // namespace fmt

template <>
Expand All @@ -45,3 +72,10 @@ struct std::hash< homeobject::BlobRoute > {
return boost::hash_value< homeobject::blob_id_t >(std::make_pair(r.shard, r.blob));
}
};

template <>
struct std::hash< homeobject::BlobRouteByChunk > {
std::size_t operator()(homeobject::BlobRouteByChunk const& r) const noexcept {
return boost::hash_value< homeobject::blob_id_t >(std::make_pair(r.shard, r.blob));
}
};
9 changes: 9 additions & 0 deletions src/lib/homestore_backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ target_sources("${PROJECT_NAME}_homestore" PRIVATE
replication_state_machine.cpp
hs_cp_callbacks.cpp
hs_http_manager.cpp
gc_manager.cpp
$<TARGET_OBJECTS:${PROJECT_NAME}_core>
)
target_link_libraries("${PROJECT_NAME}_homestore" PUBLIC
Expand Down Expand Up @@ -114,3 +115,11 @@ add_test(NAME HomestoreResyncTestWithLeaderRestart
--override_config homestore_config.generic.repl_dev_cleanup_interval_sec=5
--override_config homestore_config.consensus.max_grpc_message_size:138412032
--gtest_filter=HomeObjectFixture.RestartLeader*)

add_executable(homestore_test_gc)
target_sources(homestore_test_gc PRIVATE $<TARGET_OBJECTS:homestore_tests_gc>)
target_link_libraries(homestore_test_gc PUBLIC homeobject_homestore ${COMMON_TEST_DEPS})
add_test(NAME HomestoreTestGC COMMAND homestore_test_pg -csv error --executor immediate --config_path ./
--override_config homestore_config.consensus.snapshot_freq_distance:0
--override_config homestore_config.consensus.max_grpc_message_size:138412032)

Loading
Loading