Maybe better keeper-bench

This commit is contained in:
Antonio Andelic 2023-03-24 14:37:51 +00:00
parent f353561204
commit f7c0cca297
3 changed files with 35 additions and 2 deletions

View File

@ -162,6 +162,19 @@ ZooKeeperRequestPtr SetRequestGenerator::generate()
return request;
}
void MixedRequestGenerator::startup(Coordination::ZooKeeper & zookeeper)
{
for (auto & generator : generators)
generator->startup(zookeeper);
}
ZooKeeperRequestPtr MixedRequestGenerator::generate()
{
pcg64 rng(randomSeed());
std::uniform_int_distribution<size_t> distribution(0, generators.size() - 1);
return generators[distribution(rng)]->generate();
}
void GetRequestGenerator::startup(Coordination::ZooKeeper & zookeeper)
{
@ -315,7 +328,13 @@ std::unique_ptr<IGenerator> getGenerator(const std::string & name)
{
return std::make_unique<SetRequestGenerator>("/set_generator", 5);
}
else if (name == "mixed_small_data")
{
std::vector<std::unique_ptr<IGenerator>> generators;
generators.push_back(std::make_unique<SetRequestGenerator>("/set_generator", 5));
generators.push_back(std::make_unique<GetRequestGenerator>("/get_generator", 10, 32));
return std::make_unique<MixedRequestGenerator>(std::move(generators));
}
throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Unknown generator {}", name);
}

View File

@ -122,5 +122,19 @@ private:
uint64_t data_size;
};
class MixedRequestGenerator final : public IGenerator
{
public:
explicit MixedRequestGenerator(std::vector<std::unique_ptr<IGenerator>> generators_)
: generators(std::move(generators_))
{}
void startup(Coordination::ZooKeeper & zookeeper) override;
Coordination::ZooKeeperRequestPtr generate() override;
private:
std::vector<std::unique_ptr<IGenerator>> generators;
};
std::unique_ptr<IGenerator> getGenerator(const std::string & name);

View File

@ -159,9 +159,9 @@ void Runner::runBenchmark()
std::cerr << "Prepared\n";
try
{
auto connections = getConnections();
for (size_t i = 0; i < concurrency; ++i)
{
auto connections = getConnections();
pool.scheduleOrThrowOnError([this, connections]() mutable { thread(connections); });
}
}