Skip to content
Open
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
91 changes: 91 additions & 0 deletions cloud/filestore/libs/storage/tablet/bench/tablet_bench.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include <cloud/filestore/libs/storage/tablet/tablet.h>

#include <cloud/filestore/libs/storage/testlib/tablet_client.h>
#include <cloud/filestore/libs/storage/testlib/test_env.h>

#include <library/cpp/testing/benchmark/bench.h>

#include <util/generic/singleton.h>
#include <util/generic/vector.h>

#include <memory>

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<TIndexTabletClient> 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<ui64>());

ui32 nodeIdx = Env.CreateNode("nfs");
ui64 tabletId = Env.BootIndexTablet(nodeIdx);

TabletClient = std::make_unique<TIndexTabletClient>(
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<ui64>();
return SingletonWithPriority<TTabletSetup, Priority>();
}

} // 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);
}
}
21 changes: 21 additions & 0 deletions cloud/filestore/libs/storage/tablet/bench/ya.make
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions cloud/filestore/libs/storage/tablet/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ RECURSE(
)

RECURSE_FOR_TESTS(
bench
ut
ut_cache_stress
ut_counters
Expand Down
10 changes: 7 additions & 3 deletions contrib/ydb/library/actors/util/local_process_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ class TEnumProcessKey {

static size_t GetIndex(const EnumT key) {
ui32 index = static_cast<ui32>(key);
Y_ABORT_UNLESS(index < Enum2Index.size());
return Enum2Index[index];
const auto& enum2Index = Singleton<TEnum2Index>()->Enum2Index;
Y_ABORT_UNLESS(index < enum2Index.size());
return enum2Index[index];
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upload this change to YDB repository

}

private:
Expand All @@ -153,5 +154,8 @@ class TEnumProcessKey {
return enum2Index;
}

inline static TVector<size_t> Enum2Index = RegisterAll();
struct TEnum2Index
{
TVector<size_t> Enum2Index = RegisterAll();
};
};
Loading