diff --git a/cloud/filestore/libs/storage/tablet/bench/tablet_bench.cpp b/cloud/filestore/libs/storage/tablet/bench/tablet_bench.cpp new file mode 100644 index 00000000000..407425bcbca --- /dev/null +++ b/cloud/filestore/libs/storage/tablet/bench/tablet_bench.cpp @@ -0,0 +1,91 @@ +#include + +#include +#include + +#include + +#include +#include + +#include + +using namespace NCloud; +using namespace NCloud::NFileStore; +using namespace NCloud::NFileStore::NStorage; + +namespace { + +//////////////////////////////////////////////////////////////////////////////// + +constexpr ui32 BlockSize = 4096; +constexpr ui64 FileSize = 1_MB; +constexpr ui64 MixedBlocksOffloadedRangesCapacity = 1000000; + +struct TTabletSetup +{ + TTestEnv Env; + std::unique_ptr TabletClient; + ui64 Handle = 0; + + TTabletSetup() + : Env(TTestEnvConfig{ + // Turn off logging in order to reduce performance overhead + .LogPriority_NFS = NActors::NLog::PRI_ALERT, + .LogPriority_KiKiMR = NActors::NLog::PRI_ALERT, + .LogPriority_Others = NActors::NLog::PRI_ALERT}) + { + NCloud::NFileStore::NProto::TStorageConfig storageConfig; + storageConfig.SetInMemoryIndexCacheEnabled(true); + storageConfig.SetMixedBlocksOffloadedRangesCapacity( + MixedBlocksOffloadedRangesCapacity); + + Env.UpdateStorageConfig(std::move(storageConfig)); + + Env.CreateSubDomain("nfs"); + Env.GetRuntime().SetDispatchedEventsLimit(Max()); + + ui32 nodeIdx = Env.CreateNode("nfs"); + ui64 tabletId = Env.BootIndexTablet(nodeIdx); + + TabletClient = std::make_unique( + Env.GetRuntime(), + nodeIdx, + tabletId, + TFileSystemConfig{.BlockSize = BlockSize}); + TabletClient->InitSession("client", "session"); + + auto nodeId = CreateNode( + *TabletClient, + TCreateNodeArgs::File(RootNodeId, "test")); + + Handle = CreateHandle(*TabletClient, nodeId); + TabletClient->WriteData(Handle, 0, FileSize, '1'); + } + + void DescribeData(ui64 offset, ui64 length) + { + auto response = TabletClient->DescribeData(Handle, offset, length); + Y_ABORT_UNLESS(FileSize == response->Record.GetFileSize()); + } +}; + +TTabletSetup* GetOrCreateTablet() +{ + // Ensure this singleton is destroyed first to avoid a crash + constexpr ui64 Priority = Max(); + return SingletonWithPriority(); +} + +} // namespace + +//////////////////////////////////////////////////////////////////////////////// + +Y_CPU_BENCHMARK(TTablet_DescribeData_1MiBRequestSize, iface) +{ + auto* tablet = GetOrCreateTablet(); + + for (size_t i = 0; i < iface.Iterations(); ++i) { + tablet->DescribeData(0, 1_MB); + } +} diff --git a/cloud/filestore/libs/storage/tablet/bench/ya.make b/cloud/filestore/libs/storage/tablet/bench/ya.make new file mode 100644 index 00000000000..e250cbb6a16 --- /dev/null +++ b/cloud/filestore/libs/storage/tablet/bench/ya.make @@ -0,0 +1,21 @@ +Y_BENCHMARK() + +IF (SANITIZER_TYPE) + TAG(ya:manual) +ENDIF() + +SRCS( + tablet_bench.cpp +) + +PEERDIR( + cloud/filestore/libs/storage/testlib +) + +PEERDIR( + cloud/filestore/libs/storage/tablet +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/cloud/filestore/libs/storage/tablet/ya.make b/cloud/filestore/libs/storage/tablet/ya.make index 4f3b58537b2..5ed6f5ba25e 100644 --- a/cloud/filestore/libs/storage/tablet/ya.make +++ b/cloud/filestore/libs/storage/tablet/ya.make @@ -134,6 +134,7 @@ RECURSE( ) RECURSE_FOR_TESTS( + bench ut ut_cache_stress ut_counters diff --git a/contrib/ydb/library/actors/util/local_process_key.h b/contrib/ydb/library/actors/util/local_process_key.h index bff8bef81b7..68d2025caa4 100644 --- a/contrib/ydb/library/actors/util/local_process_key.h +++ b/contrib/ydb/library/actors/util/local_process_key.h @@ -131,8 +131,9 @@ class TEnumProcessKey { static size_t GetIndex(const EnumT key) { ui32 index = static_cast(key); - Y_ABORT_UNLESS(index < Enum2Index.size()); - return Enum2Index[index]; + const auto& enum2Index = Singleton()->Enum2Index; + Y_ABORT_UNLESS(index < enum2Index.size()); + return enum2Index[index]; } private: @@ -153,5 +154,8 @@ class TEnumProcessKey { return enum2Index; } - inline static TVector Enum2Index = RegisterAll(); + struct TEnum2Index + { + TVector Enum2Index = RegisterAll(); + }; };