mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00:00
chore: Benchmark huge values migration breakdown (CmdSerializer
)
Related to #4278
This commit is contained in:
parent
44e27efc00
commit
d5e4b552d7
2 changed files with 85 additions and 2 deletions
|
@ -28,7 +28,7 @@ endif()
|
||||||
|
|
||||||
add_library(dfly_transaction db_slice.cc blocking_controller.cc
|
add_library(dfly_transaction db_slice.cc blocking_controller.cc
|
||||||
command_registry.cc cluster/cluster_utility.cc
|
command_registry.cc cluster/cluster_utility.cc
|
||||||
journal/cmd_serializer.cc journal/tx_executor.cc namespaces.cc
|
journal/tx_executor.cc namespaces.cc
|
||||||
common.cc journal/journal.cc journal/types.cc journal/journal_slice.cc
|
common.cc journal/journal.cc journal/types.cc journal/journal_slice.cc
|
||||||
server_state.cc table.cc top_keys.cc transaction.cc tx_base.cc
|
server_state.cc table.cc top_keys.cc transaction.cc tx_base.cc
|
||||||
serializer_commons.cc journal/serializer.cc journal/executor.cc journal/streamer.cc
|
serializer_commons.cc journal/serializer.cc journal/executor.cc journal/streamer.cc
|
||||||
|
@ -43,7 +43,7 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||||
cxx_test(tiered_storage_test dfly_test_lib LABELS DFLY)
|
cxx_test(tiered_storage_test dfly_test_lib LABELS DFLY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(dragonfly_lib bloom_family.cc
|
add_library(dragonfly_lib bloom_family.cc journal/cmd_serializer.cc
|
||||||
config_registry.cc conn_context.cc debugcmd.cc dflycmd.cc engine_shard.cc
|
config_registry.cc conn_context.cc debugcmd.cc dflycmd.cc engine_shard.cc
|
||||||
engine_shard_set.cc family_utils.cc
|
engine_shard_set.cc family_utils.cc
|
||||||
generic_family.cc hset_family.cc http_api.cc json_family.cc
|
generic_family.cc hset_family.cc http_api.cc json_family.cc
|
||||||
|
@ -115,6 +115,7 @@ cxx_test(zset_family_test dfly_test_lib LABELS DFLY)
|
||||||
cxx_test(blocking_controller_test dfly_test_lib LABELS DFLY)
|
cxx_test(blocking_controller_test dfly_test_lib LABELS DFLY)
|
||||||
cxx_test(json_family_test dfly_test_lib LABELS DFLY)
|
cxx_test(json_family_test dfly_test_lib LABELS DFLY)
|
||||||
cxx_test(journal/journal_test dfly_test_lib LABELS DFLY)
|
cxx_test(journal/journal_test dfly_test_lib LABELS DFLY)
|
||||||
|
cxx_test(journal/cmd_serializer_test dfly_test_lib LABELS DFLY)
|
||||||
cxx_test(top_keys_test dfly_test_lib LABELS DFLY)
|
cxx_test(top_keys_test dfly_test_lib LABELS DFLY)
|
||||||
cxx_test(hll_family_test dfly_test_lib LABELS DFLY)
|
cxx_test(hll_family_test dfly_test_lib LABELS DFLY)
|
||||||
cxx_test(bloom_family_test dfly_test_lib LABELS DFLY)
|
cxx_test(bloom_family_test dfly_test_lib LABELS DFLY)
|
||||||
|
|
82
src/server/journal/cmd_serializer_test.cc
Normal file
82
src/server/journal/cmd_serializer_test.cc
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
// Copyright 2024, DragonflyDB authors. All rights reserved.
|
||||||
|
// See LICENSE for licensing terms.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "server/journal/cmd_serializer.h"
|
||||||
|
|
||||||
|
#include "base/gtest.h"
|
||||||
|
#include "base/logging.h"
|
||||||
|
#include "core/string_set.h"
|
||||||
|
#include "server/test_utils.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "redis/zmalloc.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace testing;
|
||||||
|
using namespace std;
|
||||||
|
using benchmark::DoNotOptimize;
|
||||||
|
|
||||||
|
namespace dfly {
|
||||||
|
|
||||||
|
static void SetUpTestSuite() {
|
||||||
|
InitRedisTables(); // to initialize server struct.
|
||||||
|
|
||||||
|
auto* tlh = mi_heap_get_backing();
|
||||||
|
init_zmalloc_threadlocal(tlh);
|
||||||
|
SmallString::InitThreadLocal(tlh);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TearDownTestSuite() {
|
||||||
|
mi_heap_collect(mi_heap_get_backing(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2 args: threshold and value size
|
||||||
|
void BM_SerializerThresholdSet(benchmark::State& state) {
|
||||||
|
ServerState::Init(0, 1, nullptr);
|
||||||
|
SetUpTestSuite();
|
||||||
|
MiMemoryResource mi(mi_heap_get_backing());
|
||||||
|
CompactObj::InitThreadLocal(&mi);
|
||||||
|
|
||||||
|
auto threshold = state.range(0);
|
||||||
|
auto val_size = state.range(1);
|
||||||
|
string_view k = "key";
|
||||||
|
CmdSerializer serializer([](std::string s) { DoNotOptimize(s); }, threshold);
|
||||||
|
absl::InsecureBitGen eng;
|
||||||
|
|
||||||
|
{
|
||||||
|
// Allocations must be done on the heap using mimalloc, as we use mimalloc API in many places
|
||||||
|
auto* key = CompactObj::AllocateMR<PrimeValue>(k);
|
||||||
|
auto* value = CompactObj::AllocateMR<PrimeValue>();
|
||||||
|
|
||||||
|
StringSet* s = CompactObj::AllocateMR<StringSet>();
|
||||||
|
for (unsigned int i = 0; i < val_size; ++i) {
|
||||||
|
s->Add(GetRandomHex(eng, 100));
|
||||||
|
}
|
||||||
|
value->InitRobj(OBJ_SET, kEncodingStrMap2, s);
|
||||||
|
|
||||||
|
while (state.KeepRunning()) {
|
||||||
|
serializer.SerializeEntry(k, *key, *value, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
CompactObj::DeleteMR<PrimeValue>(value);
|
||||||
|
CompactObj::DeleteMR<PrimeValue>(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
TearDownTestSuite();
|
||||||
|
ServerState::Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK(BM_SerializerThresholdSet)
|
||||||
|
->Args({0, 1})
|
||||||
|
->Args({100, 1})
|
||||||
|
->Args({0, 10})
|
||||||
|
->Args({1000, 10})
|
||||||
|
->Args({0, 100})
|
||||||
|
->Args({10'000, 100})
|
||||||
|
->Args({0, 1'000})
|
||||||
|
->Args({100'000, 1'000})
|
||||||
|
->Args({0, 1'000'000})
|
||||||
|
->Args({100'000, 1'000'000});
|
||||||
|
|
||||||
|
} // namespace dfly
|
Loading…
Reference in a new issue