Skip to content
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
1 change: 0 additions & 1 deletion mooncake-store/include/allocation_strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ class AllocatorManager {
allocators_;
std::unordered_map<std::string, UUID> owner_by_name_;
friend class ScopedSegmentAccess;
friend class SegmentSerializer;
};

/**
Expand Down
37 changes: 0 additions & 37 deletions mooncake-store/include/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ class AllocatedBuffer {
std::optional<offset_allocator::OffsetAllocationHandle> offset_handle_{
std::nullopt};

friend class Serializer<AllocatedBuffer>;
friend class Replica;
friend class SegmentAllocatorRegistration;
};
Expand Down Expand Up @@ -349,26 +348,6 @@ std::optional<RestoredCachelibBufferAllocator> ImportCachelibBufferAllocator(
const std::vector<LiveAllocation>& allocations,
ReplicaType replica_type = ReplicaType::MEMORY);

// A detached capture of host-memory allocator metadata; owns no live allocator
// and contributes neither usage nor capacity metrics.
struct OffsetBufferAllocatorSnapshot {
std::string segment_name;
size_t base;
size_t capacity;
size_t used_bytes;
std::string transport_endpoint;
offset_allocator::OffsetAllocatorSnapshot allocation_state;

// Validate the detached snapshot without publishing resources or metrics.
[[nodiscard]] tl::expected<void, std::string> Validate() const;

private:
tl::expected<void, std::string> ValidateMetadata() const;
// Restore composes this cheap outer check with OffsetAllocator::Restore's
// mandatory layout validation, avoiding two graph scans in one factory.
friend class OffsetBufferAllocator;
};

/**
* OffsetBufferAllocator manages memory allocation using the OffsetAllocator
* strategy, which provides efficient memory allocation with bin-based
Expand All @@ -384,18 +363,6 @@ class OffsetBufferAllocator

~OffsetBufferAllocator() override;

// Restore an unpublished allocator from decoded state. Installs the
// allocation layout and accounts usage before returning a runtime-ready
// object; capacity accounting remains the owning pool's responsibility.
// Consumes the snapshot and rejects inconsistent state with
// ErrorCode::INVALID_PARAMS.
static tl::expected<std::shared_ptr<OffsetBufferAllocator>, ErrorCode>
Restore(OffsetBufferAllocatorSnapshot snapshot);

// Requires a forked snapshot child or externally quiesced state. Does not
// acquire inherited runtime locks; copies all state needed by the codec.
OffsetBufferAllocatorSnapshot CaptureSnapshot() const;

std::unique_ptr<AllocatedBuffer> allocate(size_t size) override;

void deallocate(AllocatedBuffer* handle) override;
Expand All @@ -420,10 +387,6 @@ class OffsetBufferAllocator
}

private:
OffsetBufferAllocator(
OffsetBufferAllocatorSnapshot snapshot,
std::shared_ptr<offset_allocator::OffsetAllocator> offset_allocator);

// metadata
const std::string segment_name_;
const size_t base_;
Expand Down
22 changes: 0 additions & 22 deletions mooncake-store/include/ha/snapshot/allocator_snapshot_codec.h

This file was deleted.

20 changes: 0 additions & 20 deletions mooncake-store/include/ha/snapshot/local_ssd_codec.h

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions mooncake-store/include/local_ssd/manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <vector>
#include <ylt/util/tl/expected.hpp>

#include "local_ssd/persisted_state.h"
#include "mutex.h"
#include "tenant_id.h"
#include "types.h"
Expand Down Expand Up @@ -106,8 +105,6 @@ class LocalSsdManager {
void RequestRemoveAll(const std::vector<UUID>& clients);
tl::expected<bool, ErrorCode> ConsumeRemoveAll(const UUID& client_id);

LocalSsdPersistedState ExportPersistedState() const;
void RestorePersistedState(LocalSsdPersistedState state);
void Clear();

private:
Expand Down
22 changes: 0 additions & 22 deletions mooncake-store/include/local_ssd/persisted_state.h

This file was deleted.

73 changes: 0 additions & 73 deletions mooncake-store/include/offset_allocator/offset_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <ylt/util/tl/expected.hpp>

#include "mutex.h"
#include "serialize/serializer.h"

namespace mooncake::offset_allocator {
typedef unsigned char uint8;
Expand All @@ -24,7 +23,6 @@ using NodeIndex = uint32;
// Forward declarations
class OffsetAllocator;
class __Allocator;
struct OffsetAllocatorSnapshot;

static constexpr uint32 NUM_TOP_BINS = 32;
static constexpr uint32 BINS_PER_LEAF = 8;
Expand All @@ -48,7 +46,6 @@ struct OffsetAllocation {
bool isNoSpace() const { return offset == NO_SPACE; }

friend class __Allocator;
friend class Serializer<OffsetAllocationHandle>;
friend class OffsetAllocator; // for createHandleAtNode during recovery
};

Expand Down Expand Up @@ -113,7 +110,6 @@ class OffsetAllocationHandle {
uint64_t requested_size;

friend class OffsetAllocatorTest; // for unit tests
friend class Serializer<OffsetAllocationHandle>;
};

struct OffsetAllocatorMetrics {
Expand Down Expand Up @@ -195,15 +191,6 @@ class OffsetAllocator : public std::enable_shared_from_this<OffsetAllocator> {
[[nodiscard]]
OffsetAllocatorMetrics get_metrics() const;

// Deep-copy persisted layout without locking. Only for a forked snapshot
// child or externally quiesced state; the result owns no live resources.
OffsetAllocatorSnapshot CaptureSnapshot() const;

// Consumes a captured snapshot and rebuilds the allocator from its layout.
// Validates before installing any state; returns a diagnostic on failure.
static tl::expected<std::shared_ptr<OffsetAllocator>, std::string> Restore(
OffsetAllocatorSnapshot snapshot);

// Serialize the allocator with serializer.
template <typename T>
void serialize_to(T& serializer) const;
Expand All @@ -213,7 +200,6 @@ class OffsetAllocator : public std::enable_shared_from_this<OffsetAllocator> {

private:
friend class OffsetAllocationHandle;
friend class Serializer<OffsetAllocator>;

// Internal method for Handle to free allocation (thread-safe)
void freeAllocation(const OffsetAllocation& allocation, uint64_t size);
Expand Down Expand Up @@ -242,12 +228,6 @@ class OffsetAllocator : public std::enable_shared_from_this<OffsetAllocator> {
OffsetAllocator(uint64_t base, size_t size, uint32 init_capacity,
uint32 max_capacity);

// Private constructor for creating from saved state with pre-constructed
// allocator This constructor is used during deserialization when we already
// have a reconstructed
OffsetAllocator(uint64_t base, size_t size, uint64_t multiplier_bits,
std::unique_ptr<__Allocator> allocator);

// Private constructor - initialize from serialized data
template <typename T>
OffsetAllocator(T& serializer);
Expand Down Expand Up @@ -281,9 +261,6 @@ class __Allocator {
void serialize_to(T& serializer) const;

private:
// Detaches the bin/node state for OffsetAllocator::CaptureSnapshot().
__Allocator(const __Allocator&) = default;

uint32 insertNodeIntoBin(uint32 size, uint32 dataOffset);
void removeNodeFromBin(uint32 nodeIndex);

Expand Down Expand Up @@ -313,59 +290,9 @@ class __Allocator {
uint32 m_freeOffset;

friend class OffsetAllocatorTest; // for unit tests
friend class mooncake::Serializer<__Allocator>;
friend struct OffsetAllocatorSnapshot;
friend class OffsetAllocator; // for visit_used_nodes / createHandleAtNode
};

// Owned allocation metadata. No runtime allocator, handles or mutex are
// retained. The internal bin/node layout is deeply copied during capture.
struct OffsetAllocatorSnapshot {
uint64_t base;
uint64_t multiplier_bits;
uint64_t capacity;
uint64_t allocated_size;
uint64_t allocated_num;
std::unique_ptr<__Allocator> layout;

// The host-memory allocator supports up to 64Mi metadata nodes. This is
// independent of the smaller limit used by the storage backend's byte
// serializer, and must allow snapshots of large memory segments.
static constexpr uint32_t kMaxNodes = 1u << 26;

// Used by the wire decoder before allocating/decompressing node storage.
static tl::expected<void, std::string> ValidateNodeCapacity(
uint32_t size, uint32_t current_capacity, uint32_t max_capacity,
uint32_t free_offset);

// Pure validation: no runtime allocator, metrics, logging or mutation.
// Checks headers before shifts, then layout topology and usage accounting.
// Requested sizes are not persisted per node, so allocated_size must lie
// within the range permitted by bin/unit rounding, not equal occupied
// bytes.
[[nodiscard]] tl::expected<void, std::string> Validate() const;

private:
enum class NodeState : uint8_t { kUnclassified, kUsed, kFree, kSpare };
struct LayoutUsage {
uint64_t used_nodes = 0;
uint64_t min_used_bytes = 0;
uint64_t max_used_bytes = 0;
};

tl::expected<void, std::string> ValidateHeader() const;
tl::expected<LayoutUsage, std::string> ValidateUsedNodes(
std::vector<NodeState>& state) const;
tl::expected<uint32_t, std::string> ValidateBins(
std::vector<NodeState>& state) const;
tl::expected<void, std::string> ValidateFreeStack(
std::vector<NodeState>& state, uint32_t live_nodes) const;
tl::expected<void, std::string> ValidateNeighborChain(
const std::vector<NodeState>& state, uint32_t live_nodes) const;
tl::expected<void, std::string> ValidateAccounting(
const LayoutUsage& usage) const;
};

// Template method implementations
template <typename T>
void OffsetAllocator::serialize_to(T& serializer) const {
Expand Down
3 changes: 1 addition & 2 deletions mooncake-store/include/replica.h
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,7 @@ class Replica {
data_;
ReplicaStatus status_{ReplicaStatus::UNDEFINED};

friend class Serializer<Replica>;
friend class MasterService; // For MetadataSerializer to access next_id_
friend class MasterService; // Standby restore advances next_id_
std::atomic<uint32_t> refcnt_{0};
};

Expand Down
Loading
Loading