Skip to content

Commit

Permalink
issue-999: TStorageServiceActor should not ignore TResizeFileStoreReq…
Browse files Browse the repository at this point in the history
…uest::GetPerformanceProfile() (#1001)

* issue-999: TStorageServiceActor should not ignore TResizeFileStoreRequest::GetPerformanceProfile()

* issue-999: TStorageServiceActor should not ignore TResizeFileStoreRequest::GetPerformanceProfile() - cleanup

* issue-999: TStorageServiceActor should not ignore TResizeFileStoreRequest::GetPerformanceProfile() - fixed model_ut.cpp build
  • Loading branch information
qkrorlqr authored Apr 18, 2024
1 parent 1ca8691 commit c29425d
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 44 deletions.
68 changes: 36 additions & 32 deletions cloud/filestore/libs/storage/core/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,26 @@ ui32 NodesLimit(

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

#define PERFORMANCE_PROFILE_PARAMETERS_SIMPLE(xxx, ...) \
xxx(ThrottlingEnabled, __VA_ARGS__) \
xxx(BoostTime, __VA_ARGS__) \
xxx(BoostRefillTime, __VA_ARGS__) \
xxx(BurstPercentage, __VA_ARGS__) \
xxx(DefaultPostponedRequestWeight, __VA_ARGS__) \
xxx(MaxPostponedWeight, __VA_ARGS__) \
xxx(MaxWriteCostMultiplier, __VA_ARGS__) \
xxx(MaxPostponedTime, __VA_ARGS__) \
xxx(MaxPostponedCount, __VA_ARGS__) \
// PERFORMANCE_PROFILE_PARAMETERS_SIMPLE

#define PERFORMANCE_PROFILE_PARAMETERS_AU(xxx, ...) \
xxx(MaxReadIops, __VA_ARGS__) \
xxx(MaxReadBandwidth, __VA_ARGS__) \
xxx(MaxWriteIops, __VA_ARGS__) \
xxx(MaxWriteBandwidth, __VA_ARGS__) \
xxx(BoostPercentage, __VA_ARGS__) \
// PERFORMANCE_PROFILE_PARAMETERS_AU

void SetupFileStorePerformanceAndChannels(
bool allocateMixed0Channel,
const TStorageConfig& config,
Expand All @@ -452,29 +472,25 @@ void SetupFileStorePerformanceAndChannels(

OverrideStorageMediaKind(config, fileStore);

#define SETUP_PARAMETER(name, ...) \
#define SETUP_PARAMETER_SIMPLE(name, ...) \
fileStore.SetPerformanceProfile##name( \
clientProfile.Get##name() \
? clientProfile.Get##name() \
: name(config, fileStore)); \
// SETUP_PARAMETER_AU

#define SETUP_PARAMETER_AU(name, ...) \
fileStore.SetPerformanceProfile##name( \
clientProfile.Get##name() \
? clientProfile.Get##name() \
: name(config, fileStore, ## __VA_ARGS__)); \
// SETUP_PARAMENTS

SETUP_PARAMETER(ThrottlingEnabled);
SETUP_PARAMETER(MaxReadIops, allocationUnitCount);
SETUP_PARAMETER(MaxReadBandwidth, allocationUnitCount);
SETUP_PARAMETER(MaxWriteIops, allocationUnitCount);
SETUP_PARAMETER(MaxWriteBandwidth, allocationUnitCount);
SETUP_PARAMETER(BoostTime);
SETUP_PARAMETER(BoostRefillTime);
SETUP_PARAMETER(BoostPercentage, allocationUnitCount);
SETUP_PARAMETER(BurstPercentage);
SETUP_PARAMETER(DefaultPostponedRequestWeight);
SETUP_PARAMETER(MaxPostponedWeight);
SETUP_PARAMETER(MaxWriteCostMultiplier);
SETUP_PARAMETER(MaxPostponedTime);
SETUP_PARAMETER(MaxPostponedCount);

#undef SETUP_PARAMENTER
: name(config, fileStore, allocationUnitCount)); \
// SETUP_PARAMETER_SIMPLE

PERFORMANCE_PROFILE_PARAMETERS_SIMPLE(SETUP_PARAMETER_SIMPLE);
PERFORMANCE_PROFILE_PARAMETERS_AU(SETUP_PARAMETER_AU);

#undef SETUP_PARAMETER_SIMPLE
#undef SETUP_PARAMETER_AU

fileStore.SetNodesCount(NodesLimit(config, fileStore));

Expand All @@ -485,16 +501,4 @@ void SetupFileStorePerformanceAndChannels(
fileStore);
}

void SetupFileStorePerformanceAndChannels(
bool allocateMixed0Channel,
const TStorageConfig& config,
NKikimrFileStore::TConfig& fileStore)
{
SetupFileStorePerformanceAndChannels(
allocateMixed0Channel,
config,
fileStore,
NProto::TFileStorePerformanceProfile());
}

} // namespace NCloud::NFileStore::NStorage
5 changes: 0 additions & 5 deletions cloud/filestore/libs/storage/core/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,4 @@ void SetupFileStorePerformanceAndChannels(
NKikimrFileStore::TConfig& fileStore,
const NProto::TFileStorePerformanceProfile& clientPerformanceProfile);

void SetupFileStorePerformanceAndChannels(
bool allocateMixed0Channel,
const TStorageConfig& config,
NKikimrFileStore::TConfig& fileStore);

} // namespace NCloud::NFileStore::NStorage
15 changes: 15 additions & 0 deletions cloud/filestore/libs/storage/core/model_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ namespace {

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

void SetupFileStorePerformanceAndChannels(
bool allocateMixed0Channel,
const TStorageConfig& config,
NKikimrFileStore::TConfig& fileStore)
{
SetupFileStorePerformanceAndChannels(
allocateMixed0Channel,
config,
fileStore,
{} // clientPerformanceProfile
);
}

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

struct TConfigs
: public NUnitTest::TBaseFixture
{
Expand Down
11 changes: 7 additions & 4 deletions cloud/filestore/libs/storage/service/service_actor_alterfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class TAlterFileStoreActor final
const TStorageConfigPtr StorageConfig;
const TRequestInfoPtr RequestInfo;
const TString FileSystemId;
const NProto::TFileStorePerformanceProfile PerformanceProfile;
const bool Alter = false;

NKikimrFileStore::TConfig Config;
Expand Down Expand Up @@ -81,7 +82,6 @@ TAlterFileStoreActor::TAlterFileStoreActor(
, FileSystemId(request.GetFileSystemId())
, Alter(true)
{
Config.SetFileSystemId(FileSystemId);
Config.SetCloudId(request.GetCloudId());
Config.SetFolderId(request.GetFolderId());
Config.SetProjectId(request.GetProjectId());
Expand All @@ -95,8 +95,8 @@ TAlterFileStoreActor::TAlterFileStoreActor(
: StorageConfig(std::move(storageConfig))
, RequestInfo(std::move(requestInfo))
, FileSystemId(request.GetFileSystemId())
, PerformanceProfile(request.GetPerformanceProfile())
{
Config.SetFileSystemId(FileSystemId);
Config.SetBlocksCount(request.GetBlocksCount());
Config.SetVersion(request.GetConfigVersion());
}
Expand Down Expand Up @@ -138,7 +138,9 @@ void TAlterFileStoreActor::HandleDescribeFileStoreResponse(

if (!Alter) {
if (config.GetBlocksCount() > Config.GetBlocksCount()) {
ReplyAndDie(ctx, MakeError(E_ARGUMENT, "Cannot decrease filestore size"));
ReplyAndDie(
ctx,
MakeError(E_ARGUMENT, "Cannot decrease filestore size"));
return;
}

Expand All @@ -151,7 +153,8 @@ void TAlterFileStoreActor::HandleDescribeFileStoreResponse(
SetupFileStorePerformanceAndChannels(
allocateMixed0,
*StorageConfig,
config);
config,
PerformanceProfile);
} else {
if (const auto& cloud = Config.GetCloudId()) {
config.SetCloudId(cloud);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ void TStorageServiceActor::HandleDescribeFileStoreModel(
SetupFileStorePerformanceAndChannels(
false, // do not allocate mixed0 channel
*StorageConfig,
config);
config,
{} // clientPerformanceProfile
);

auto response = std::make_unique<TEvService::TEvDescribeFileStoreModelResponse>();
auto* model = response->Record.MutableFileStoreModel();
Expand Down
64 changes: 63 additions & 1 deletion cloud/filestore/libs/storage/service/service_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,68 @@ Y_UNIT_TEST_SUITE(TStorageServiceTest)
service.AssertResizeFileStoreFailed("test", 0);
}

Y_UNIT_TEST(ShouldResizeFileStoreWithCustomPerformanceProfile)
{
TTestEnv env;
env.CreateSubDomain("nfs");

ui32 nodeIdx = env.CreateNode("nfs");

TServiceClient service(env.GetRuntime(), nodeIdx);
const char* fsId = "test";
const auto initialBlockCount = 1'000;
const auto blockCount = 100'000'000;
const auto customMaxReadIops = 111;
const auto customMaxWriteIops = 222;
service.CreateFileStore("test", initialBlockCount);
auto resizeRequest = service.CreateResizeFileStoreRequest(
"test",
blockCount);
resizeRequest->Record.MutablePerformanceProfile()->SetMaxReadIops(
customMaxReadIops);
service.SendRequest(MakeStorageServiceId(), std::move(resizeRequest));
auto resizeResponse = service.RecvResizeFileStoreResponse();
UNIT_ASSERT_VALUES_EQUAL_C(
S_OK,
resizeResponse->GetStatus(),
resizeResponse->GetErrorReason());

auto response = service.GetFileStoreInfo(fsId)->Record.GetFileStore();
UNIT_ASSERT_VALUES_EQUAL(fsId, response.GetFileSystemId());
UNIT_ASSERT_VALUES_EQUAL(blockCount, response.GetBlocksCount());

auto profile = response.GetPerformanceProfile();
UNIT_ASSERT(!profile.GetThrottlingEnabled());
// autocalculated
UNIT_ASSERT_VALUES_EQUAL(600, profile.GetMaxWriteIops());
// custom
UNIT_ASSERT_VALUES_EQUAL(customMaxReadIops, profile.GetMaxReadIops());

resizeRequest = service.CreateResizeFileStoreRequest(
"test",
blockCount);
resizeRequest->Record.MutablePerformanceProfile()->SetMaxWriteIops(
customMaxWriteIops);

service.SendRequest(MakeStorageServiceId(), std::move(resizeRequest));
resizeResponse = service.RecvResizeFileStoreResponse();
UNIT_ASSERT_VALUES_EQUAL_C(
S_OK,
resizeResponse->GetStatus(),
resizeResponse->GetErrorReason());

response = service.GetFileStoreInfo(fsId)->Record.GetFileStore();
UNIT_ASSERT_VALUES_EQUAL(fsId, response.GetFileSystemId());
UNIT_ASSERT_VALUES_EQUAL(blockCount, response.GetBlocksCount());

profile = response.GetPerformanceProfile();
UNIT_ASSERT(!profile.GetThrottlingEnabled());
// custom
UNIT_ASSERT_VALUES_EQUAL(customMaxWriteIops, profile.GetMaxWriteIops());
// autocalculated
UNIT_ASSERT_VALUES_EQUAL(200, profile.GetMaxReadIops());
}

Y_UNIT_TEST(ShouldResizeFileStoreAndAddChannels)
{
TTestEnv env;
Expand Down Expand Up @@ -208,7 +270,7 @@ Y_UNIT_TEST_SUITE(TStorageServiceTest)
}
return TTestActorRuntime::DefaultObserverFunc(event);
});
service.ResizeFileStore("test", 4_TB/DefaultBlockSize);
service.ResizeFileStore("test", 4_TB / DefaultBlockSize);
UNIT_ASSERT(alterChannelsCount > 0);
UNIT_ASSERT(alterChannelsCount > createChannelsCount);
}
Expand Down
4 changes: 3 additions & 1 deletion cloud/filestore/libs/storage/testlib/ss_proxy_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class TSSProxyClient
SetupFileStorePerformanceAndChannels(
false, // do not allocate mixed0 channel
*StorageConfig,
config);
config,
{} // clientPerformanceProfile
);

return std::make_unique<TEvSSProxy::TEvCreateFileStoreRequest>(config);
}
Expand Down

0 comments on commit c29425d

Please sign in to comment.