| 235 | // job scheduler settings |
| 236 | |
| 237 | void NavyConfig::setReaderAndWriterThreads(unsigned int readerThreads, |
| 238 | unsigned int writerThreads, |
| 239 | unsigned int maxNumReads, |
| 240 | unsigned int maxNumWrites, |
| 241 | unsigned int stackSizeKB) { |
| 242 | readerThreads_ = readerThreads; |
| 243 | writerThreads_ = writerThreads; |
| 244 | maxNumReads_ = maxNumReads; |
| 245 | maxNumWrites_ = maxNumWrites; |
| 246 | stackSize_ = stackSizeKB * 1024; |
| 247 | |
| 248 | if ((maxNumReads > 0 && maxNumWrites == 0) || |
| 249 | (maxNumReads == 0 && maxNumWrites > 0)) { |
| 250 | throw std::invalid_argument( |
| 251 | "maxNumReads and maxNumWrites should be both 0 or both >0"); |
| 252 | } |
| 253 | |
| 254 | // Limit the fiber stack size to 1MB to prevent any misconfiguration; |
| 255 | // The 1MB is too large for most use cases and there will be |
| 256 | // lots of memory amounts to >800MB per thread wasted |
| 257 | if (stackSizeKB >= 1024) { |
| 258 | throw std::invalid_argument( |
| 259 | "Maximum fiber stack size for each thread should be less than 1024 KB"); |
| 260 | } |
| 261 | |
| 262 | if (maxNumReads > 0 || maxNumWrites > 0) { |
| 263 | if ((maxNumReads % readerThreads_) || (maxNumWrites % writerThreads_)) { |
| 264 | throw std::invalid_argument(folly::sformat( |
| 265 | "reader threads ({}) and writer threads ({}) should divide evenly " |
| 266 | "into maxNumReads ({}) or maxNumWrites ({})", |
| 267 | readerThreads_, writerThreads_, maxNumReads, maxNumWrites)); |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | if (!qDepth_) { |
| 272 | // Adjust the device qdepth and enable async IO if needed |
| 273 | qDepth_ = |
| 274 | std::max(maxNumReads_ / readerThreads_, maxNumWrites_ / writerThreads_); |
| 275 | if (qDepth_ > 0) { |
| 276 | XDCHECK_EQ(ioEngine_, IoEngine::Sync); |
| 277 | // TODO: default to libaio until T182829130 is fixed |
| 278 | ioEngine_ = IoEngine::LibAio; |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | void NavyConfig::setReaderAndWriterThreads(uint32_t readerThreads, |
| 284 | uint32_t writerThreads) { |
no outgoing calls