mirror of
https://github.com/dragonflydb/dragonfly
synced 2024-11-21 15:11:20 +00:00
opt(server): If unspecified, use num_shards == proactor_threads (#1998)
* opt(server): If unspecified, use num_shards == proactor_threads * Use same config for tests, per Roman's request
This commit is contained in:
parent
cbba6f4e11
commit
b1bd2103d7
2
helio
2
helio
@ -1 +1 @@
|
||||
Subproject commit 6655f713c7cb6aebc586973ebea6d6bfea06df3c
|
||||
Subproject commit 0950c8fd612bba442caffdabd86d67a32246d461
|
@ -686,9 +686,10 @@ void Service::Init(util::AcceptServer* acceptor, std::vector<facade::Listener*>
|
||||
pp_.Await([reg](uint32_t index, ProactorBase* pb) { ServerState::Init(index, reg); });
|
||||
|
||||
uint32_t shard_num = GetFlag(FLAGS_num_shards);
|
||||
if (shard_num == 0) {
|
||||
shard_num = pp_.size() > 1 ? pp_.size() - 1 : pp_.size();
|
||||
} else if (shard_num > pp_.size()) {
|
||||
if (shard_num == 0 || shard_num > pp_.size()) {
|
||||
LOG_IF(WARNING, shard_num > pp_.size())
|
||||
<< "Requested num_shards (" << shard_num << ") is bigger than thread count (" << pp_.size()
|
||||
<< "), using num_shards=" << pp_.size();
|
||||
shard_num = pp_.size();
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ extern "C" {
|
||||
using namespace std;
|
||||
|
||||
ABSL_DECLARE_FLAG(string, dbfilename);
|
||||
ABSL_DECLARE_FLAG(uint32_t, num_shards);
|
||||
ABSL_FLAG(bool, force_epoll, false, "If true, uses epoll api instead iouring to run tests");
|
||||
|
||||
namespace dfly {
|
||||
@ -193,6 +194,10 @@ void BaseFamilyTest::ResetService() {
|
||||
pp_.reset(fb2::Pool::Epoll(num_threads_));
|
||||
#endif
|
||||
|
||||
// Using a different default than production could expose bugs
|
||||
if (absl::GetFlag(FLAGS_num_shards) == 0) {
|
||||
absl::SetFlag(&FLAGS_num_shards, num_threads_ - 1);
|
||||
}
|
||||
pp_->Run();
|
||||
service_ = std::make_unique<Service>(pp_.get());
|
||||
|
||||
|
@ -74,6 +74,14 @@ class DflyInstance:
|
||||
del self.args["logtostderr"]
|
||||
self.args["alsologtostderr"] = None
|
||||
|
||||
# Run with num_shards = (proactor_threads - 1) if possible, so help expose bugs
|
||||
if "num_shards" not in self.args:
|
||||
threads = psutil.cpu_count()
|
||||
if "proactor_threads" in self.args:
|
||||
threads = int(self.args["proactor_threads"])
|
||||
if threads > 1:
|
||||
self.args["num_shards"] = threads - 1
|
||||
|
||||
def __del__(self):
|
||||
assert self.proc == None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user