Skip to content

Commit d5a9541

Browse files
author
don-dron
committed
feat userver/ydb: add thread properties to config
Exposes `network-threads-num` and `client-threads-num` properties from ydb-cpp-sdk in @ref ydb::Component. commit_hash:7a999f3b871dbf5641bbdf3952739d834752b119
1 parent 9c1d268 commit d5a9541

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

ydb/src/ydb/component.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ properties:
6464
type: boolean
6565
default: true
6666
description: whether to use query cache
67+
network-threads-num:
68+
type: integer
69+
minimum: 1
70+
default: 2
71+
description: |
72+
Number of gRPC worker threads in YDB C++ SDK (NYdb::TDriverConfig::SetNetworkThreadsNum).
73+
Defaults to the SDK default (2).
74+
client-threads-num:
75+
type: integer
76+
minimum: 0
77+
default: 0
78+
description: |
79+
Number of threads for async user callbacks in YDB C++ SDK (NYdb::TDriverConfig::SetClientThreadsNum).
80+
0 means adaptive thread pool (SDK default).
6781
prefer_local_dc:
6882
type: boolean
6983
default: true

ydb/src/ydb/impl/config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ DriverSettings ParseDriverSettings(
6767
auto config_database = dbconfig["database"].As<std::optional<std::string>>();
6868

6969
result.prefer_local_dc = dbconfig["prefer_local_dc"].As<bool>(result.prefer_local_dc);
70+
result.network_threads_num = dbconfig["network-threads-num"].As<std::size_t>(result.network_threads_num);
71+
result.client_threads_num = dbconfig["client-threads-num"].As<std::size_t>(result.client_threads_num);
7072

7173
result.endpoint = MergeWithSecdist(dbsecdist.endpoint, std::move(config_endpoint), dbconfig, "endpoint");
7274
result.database = MergeWithSecdist(dbsecdist.database, std::move(config_database), dbconfig, "database");

ydb/src/ydb/impl/config.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <chrono>
4+
#include <cstddef>
45
#include <cstdint>
56
#include <optional>
67
#include <string>
@@ -40,6 +41,9 @@ struct DriverSettings {
4041
std::string endpoint;
4142
std::string database;
4243

44+
std::size_t network_threads_num{2};
45+
std::size_t client_threads_num{0};
46+
4347
bool prefer_local_dc{false};
4448
std::optional<std::string> oauth_token;
4549
std::optional<std::string> iam_jwt_params;

ydb/src/ydb/impl/driver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ Driver::Driver(std::string dbname, impl::DriverSettings settings)
2828
settings.prefer_local_dc
2929
? NYdb::EBalancingPolicy::UsePreferableLocation
3030
: NYdb::EBalancingPolicy::UseAllNodes
31-
);
31+
)
32+
.SetNetworkThreadsNum(settings.network_threads_num)
33+
.SetClientThreadsNum(settings.client_threads_num);
3234

3335
if (settings.secure_connection_cert.has_value()) {
3436
driver_config.UseSecureConnection(*settings.secure_connection_cert);

0 commit comments

Comments
 (0)