Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
93 changes: 93 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,93 @@
#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/vector.h>

#include <atomic>
#include <memory>

using namespace NCloud;
using namespace NCloud::NFileStore;
using namespace NCloud::NFileStore::NStorage;

namespace {

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

constexpr ui32 BlockSize = 4096;

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

struct TTabletSetup
{
TTestEnv Env;
std::unique_ptr<TIndexTabletClient> TabletClient;
ui64 Handle = 0;

TTabletSetup()
: Env(TTestEnvConfig{
.LogPriority_NFS = NActors::NLog::PRI_ALERT,
.LogPriority_KiKiMR = NActors::NLog::PRI_ALERT,
.LogPriority_Others = NActors::NLog::PRI_ALERT})
{
Env.CreateSubDomain("nfs");

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, 1_MB, '1');
}

void DescribeData(ui64 offset, ui64 length)
{
auto response = TabletClient->DescribeData(Handle, offset, length);
Y_ABORT_UNLESS(1_MB == response->Record.GetFileSize());
}
};

std::atomic<TTabletSetup*> Tablet = nullptr;

TTabletSetup* GetOrCreateTablet()
{
if (Tablet.load()) {
return Tablet.load();
}

auto tmp = std::make_unique<TTabletSetup>();
TTabletSetup* expected = nullptr;
if (!Tablet.compare_exchange_strong(expected, tmp.get())) {
return Tablet.load();
}

// Memory leak is OK here
return tmp.release();
}

} // 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
Loading