Skip to content
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

Disk registry benchmarks #2852

Merged
merged 4 commits into from
Jan 15, 2025
Merged
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: 1 addition & 0 deletions cloud/blockstore/libs/.gitignore
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ storage/disk_agent/ut/cloud-blockstore-libs-storage-disk_agent-ut
storage/disk_registry_proxy/ut/blockstore-libs-storage-disk_registry_proxy-ut
storage/disk_registry/actors/ut/libs-storage-disk_registry-actors-ut
storage/disk_registry/model/ut/blockstore-libs-storage-disk_registry-model-ut
storage/disk_registry/benchmark/benchmark
storage/disk_registry/ut_allocation/libs-storage-disk_registry-ut_allocation
storage/disk_registry/ut_checkpoint/libs-storage-disk_registry-ut_checkpoint
storage/disk_registry/ut_cms/blockstore-libs-storage-disk_registry-ut_cms
19 changes: 19 additions & 0 deletions cloud/blockstore/libs/storage/disk_registry/benchmark/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
G_BENCHMARK()

INCLUDE(${ARCADIA_ROOT}/cloud/blockstore/tests/recipes/disk-registry-state/recipe.inc)

IF (SANITIZER_TYPE)
INCLUDE(${ARCADIA_ROOT}/cloud/storage/core/tests/recipes/large.inc)
ELSE()
INCLUDE(${ARCADIA_ROOT}/cloud/storage/core/tests/recipes/medium.inc)
ENDIF()

SRCS(
../disk_registry_state_benchmark.cpp
)

PEERDIR(
cloud/blockstore/libs/storage/disk_registry/testlib
)

END()
Original file line number Diff line number Diff line change
@@ -502,6 +502,8 @@ class TDiskRegistryActor final
} \
// BLOCKSTORE_DISK_REGISTRY_COUNTER

TDiskRegistryStateSnapshot MakeNewLoadState(
NProto::TDiskRegistryStateBackup&& backup);
bool ToLogicalBlocks(NProto::TDeviceConfig& device, ui32 logicalBlockSize);
TString LogDevices(const TVector<NProto::TDeviceConfig>& devices);

Original file line number Diff line number Diff line change
@@ -15,120 +15,6 @@ namespace {

////////////////////////////////////////////////////////////////////////////////

TDiskRegistryStateSnapshot MakeNewLoadState(
drbasic marked this conversation as resolved.
Show resolved Hide resolved
NProto::TDiskRegistryStateBackup&& backup)
{
auto move = [] (auto& src, auto& dst) {
dst.reserve(src.size());
dst.assign(
std::make_move_iterator(src.begin()),
std::make_move_iterator(src.end()));
src.Clear();
};

auto transform = [] (auto& src, auto& dst, auto func) {
dst.resize(src.size());
for (int i = 0; i < src.size(); ++i) {
func(src[i], dst[i]);
}
src.Clear();
};

TDiskRegistryStateSnapshot newLoadState;
// if new fields are added to TDiskRegistryStateSnapshot
// there will be a compilation error.
auto& [
config,
dirtyDevices,
agents,
disks,
placementGroups,
brokenDisks,
disksToReallocate,
diskStateChanges,
lastDiskStateSeqNo,
writableState,
disksToCleanup,
errorNotifications,
userNotifications,
outdatedVolumeConfigs,
suspendedDevices,
automaticallyReplacedDevices,
diskRegistryAgentListParams
] = newLoadState;

if (backup.DirtyDevicesSize()) {
transform(
*backup.MutableDirtyDevices(),
dirtyDevices,
[] (auto& src, auto& dst) {
dst.Id = src.GetId();
dst.DiskId = src.GetDiskId();
});
} else {
transform(
*backup.MutableOldDirtyDevices(),
dirtyDevices,
[] (auto& src, auto& dst) {
dst.Id = src;
});
}

move(*backup.MutableAgents(), agents);
move(*backup.MutableDisks(), disks);
move(*backup.MutablePlacementGroups(), placementGroups);
move(*backup.MutableDisksToNotify(), disksToReallocate);
move(*backup.MutableDisksToCleanup(), disksToCleanup);

move(*backup.MutableErrorNotifications(), errorNotifications);
move(*backup.MutableUserNotifications(), userNotifications);
// Filter out unknown events for future version rollback compatibility
std::erase_if(userNotifications, [] (const auto& notif) {
return notif.GetEventCase()
== NProto::TUserNotification::EventCase::EVENT_NOT_SET;
});

move(*backup.MutableOutdatedVolumeConfigs(), outdatedVolumeConfigs);
move(*backup.MutableSuspendedDevices(), suspendedDevices);

transform(
*backup.MutableBrokenDisks(),
brokenDisks,
[] (auto& src, auto& dst) {
dst.DiskId = src.GetDiskId();
dst.TsToDestroy = TInstant::MicroSeconds(src.GetTsToDestroy());
});
transform(
*backup.MutableDiskStateChanges(),
diskStateChanges,
[] (auto& src, auto& dst) {
if (src.HasState()) {
dst.State.Swap(src.MutableState());
}
dst.SeqNo = src.GetSeqNo();
});
transform(
*backup.MutableAutomaticallyReplacedDevices(),
automaticallyReplacedDevices,
[] (auto& src, auto& dst) {
dst.DeviceId = src.GetDeviceId();
dst.ReplacementTs = TInstant::MicroSeconds(src.GetReplacementTs());
});

diskRegistryAgentListParams.insert(
backup.MutableDiskRegistryAgentListParams()->begin(),
backup.MutableDiskRegistryAgentListParams()->end());

if (backup.HasConfig()) {
config.Swap(backup.MutableConfig());
}

lastDiskStateSeqNo = config.GetLastDiskStateSeqNo();
writableState = config.GetWritableState();

return newLoadState;
}

using TOperations = TQueue<std::function<void(TDiskRegistryDatabase&)>>;

void RestoreConfig(
@@ -440,6 +326,122 @@ void RestoreDiskRegistryAgentListParams(

////////////////////////////////////////////////////////////////////////////////

TDiskRegistryStateSnapshot MakeNewLoadState(
NProto::TDiskRegistryStateBackup&& backup)
{
auto move = [] (auto& src, auto& dst) {
dst.reserve(src.size());
dst.assign(
std::make_move_iterator(src.begin()),
std::make_move_iterator(src.end()));
src.Clear();
};

auto transform = [] (auto& src, auto& dst, auto func) {
dst.resize(src.size());
for (int i = 0; i < src.size(); ++i) {
func(src[i], dst[i]);
}
src.Clear();
};

TDiskRegistryStateSnapshot newLoadState;
// if new fields are added to TDiskRegistryStateSnapshot
// there will be a compilation error.
auto& [
config,
dirtyDevices,
agents,
disks,
placementGroups,
brokenDisks,
disksToReallocate,
diskStateChanges,
lastDiskStateSeqNo,
writableState,
disksToCleanup,
errorNotifications,
userNotifications,
outdatedVolumeConfigs,
suspendedDevices,
automaticallyReplacedDevices,
diskRegistryAgentListParams
] = newLoadState;

if (backup.DirtyDevicesSize()) {
transform(
*backup.MutableDirtyDevices(),
dirtyDevices,
[] (auto& src, auto& dst) {
dst.Id = src.GetId();
dst.DiskId = src.GetDiskId();
});
} else {
transform(
*backup.MutableOldDirtyDevices(),
dirtyDevices,
[] (auto& src, auto& dst) {
dst.Id = src;
});
}

move(*backup.MutableAgents(), agents);
move(*backup.MutableDisks(), disks);
move(*backup.MutablePlacementGroups(), placementGroups);
move(*backup.MutableDisksToNotify(), disksToReallocate);
move(*backup.MutableDisksToCleanup(), disksToCleanup);

move(*backup.MutableErrorNotifications(), errorNotifications);
move(*backup.MutableUserNotifications(), userNotifications);
// Filter out unknown events for future version rollback compatibility
std::erase_if(userNotifications, [] (const auto& notif) {
return notif.GetEventCase()
== NProto::TUserNotification::EventCase::EVENT_NOT_SET;
});

move(*backup.MutableOutdatedVolumeConfigs(), outdatedVolumeConfigs);
move(*backup.MutableSuspendedDevices(), suspendedDevices);

transform(
*backup.MutableBrokenDisks(),
brokenDisks,
[] (auto& src, auto& dst) {
dst.DiskId = src.GetDiskId();
dst.TsToDestroy = TInstant::MicroSeconds(src.GetTsToDestroy());
});
transform(
*backup.MutableDiskStateChanges(),
diskStateChanges,
[] (auto& src, auto& dst) {
if (src.HasState()) {
dst.State.Swap(src.MutableState());
}
dst.SeqNo = src.GetSeqNo();
});
transform(
*backup.MutableAutomaticallyReplacedDevices(),
automaticallyReplacedDevices,
[] (auto& src, auto& dst) {
dst.DeviceId = src.GetDeviceId();
dst.ReplacementTs = TInstant::MicroSeconds(src.GetReplacementTs());
});

diskRegistryAgentListParams.insert(
backup.MutableDiskRegistryAgentListParams()->begin(),
backup.MutableDiskRegistryAgentListParams()->end());

if (backup.HasConfig()) {
config.Swap(backup.MutableConfig());
}

lastDiskStateSeqNo = config.GetLastDiskStateSeqNo();
writableState = config.GetWritableState();

return newLoadState;
}

////////////////////////////////////////////////////////////////////////////////

void TDiskRegistryActor::HandleRestoreDiskRegistryState(
const TEvDiskRegistry::TEvRestoreDiskRegistryStateRequest::TPtr& ev,
const TActorContext& ctx)
Loading