@@ -37,6 +37,15 @@ std::string bool2String(bool value) {
37
37
return value ? " true" : " false" ;
38
38
}
39
39
40
+ int getThreadCount () {
41
+ auto numThreads = std::thread::hardware_concurrency ();
42
+ // The spec says std::thread::hardware_concurrency() might return 0.
43
+ // But we depend on std::thread::hardware_concurrency() to create executors.
44
+ // Add a check to ensure it is > 0.
45
+ VELOX_CHECK_GT (numThreads, 0 );
46
+ return numThreads;
47
+ }
48
+
40
49
#define STR_PROP (_key_, _val_ ) \
41
50
{ std::string (_key_), std::string (_val_) }
42
51
#define NUM_PROP (_key_, _val_ ) \
@@ -76,21 +85,6 @@ std::string ConfigBase::capacityPropertyAsBytesString(
76
85
velox::config::CapacityUnit::BYTE));
77
86
}
78
87
79
- bool ConfigBase::registerProperty (
80
- const std::string& propertyName,
81
- const folly::Optional<std::string>& defaultValue) {
82
- if (registeredProps_.count (propertyName) != 0 ) {
83
- PRESTO_STARTUP_LOG (WARNING)
84
- << " Property '" << propertyName
85
- << " ' is already registered with default value '"
86
- << registeredProps_[propertyName].value_or (" <none>" ) << " '." ;
87
- return false ;
88
- }
89
-
90
- registeredProps_[propertyName] = defaultValue;
91
- return true ;
92
- }
93
-
94
88
folly::Optional<std::string> ConfigBase::setValue (
95
89
const std::string& propertyName,
96
90
const std::string& value) {
@@ -138,7 +132,7 @@ SystemConfig::SystemConfig() {
138
132
BOOL_PROP (kHttpServerReusePort , false ),
139
133
BOOL_PROP (kHttpServerBindToNodeInternalAddressOnlyEnabled , false ),
140
134
NONE_PROP (kDiscoveryUri ),
141
- NUM_PROP (kMaxDriversPerTask , 16 ),
135
+ NUM_PROP (kMaxDriversPerTask , getThreadCount () ),
142
136
NONE_PROP (kTaskWriterCount ),
143
137
NONE_PROP (kTaskPartitionedWriterCount ),
144
138
NUM_PROP (kConcurrentLifespansPerTask , 1 ),
@@ -292,14 +286,16 @@ std::string SystemConfig::prestoVersion() const {
292
286
}
293
287
294
288
std::string SystemConfig::poolType () const {
295
- static const std::unordered_set<std::string> kPoolTypes = {" LEAF" , " INTERMEDIATE" , " DEFAULT" };
296
- static constexpr std::string_view kPoolTypeDefault = " DEFAULT" ;
297
- auto value = optionalProperty<std::string>(kPoolType ).value_or (std::string (kPoolTypeDefault ));
298
- VELOX_USER_CHECK (
299
- kPoolTypes .count (value),
300
- " {} must be one of 'LEAF', 'INTERMEDIATE', or 'DEFAULT'" ,
301
- kPoolType );
302
- return value;
289
+ static const std::unordered_set<std::string> kPoolTypes = {
290
+ " LEAF" , " INTERMEDIATE" , " DEFAULT" };
291
+ static constexpr std::string_view kPoolTypeDefault = " DEFAULT" ;
292
+ auto value = optionalProperty<std::string>(kPoolType ).value_or (
293
+ std::string (kPoolTypeDefault ));
294
+ VELOX_USER_CHECK (
295
+ kPoolTypes .count (value),
296
+ " {} must be one of 'LEAF', 'INTERMEDIATE', or 'DEFAULT'" ,
297
+ kPoolType );
298
+ return value;
303
299
}
304
300
305
301
bool SystemConfig::mutableConfig () const {
0 commit comments