Use folly::hardware_concurrency()

Fixes github #130.
This commit is contained in:
Marcus Holland-Moritz 2023-03-07 11:35:21 +01:00
parent de2f1a4568
commit e4971b4187
3 changed files with 10 additions and 7 deletions

View File

@ -42,6 +42,7 @@
#include <folly/container/EvictingCacheMap.h>
#include <folly/container/F14Map.h>
#include <folly/system/HardwareConcurrency.h>
#include <folly/system/ThreadName.h>
#include "dwarfs/block_cache.h"
@ -232,11 +233,11 @@ class block_cache_ final : public block_cache::impl {
, LOG_PROXY_INIT(lgr)
, options_(options) {
if (options.init_workers) {
wg_ = worker_group("blkcache",
std::max(options.num_workers > 0
? options.num_workers
: std::thread::hardware_concurrency(),
static_cast<size_t>(1)));
wg_ =
worker_group("blkcache", std::max(options.num_workers > 0
? options.num_workers
: folly::hardware_concurrency(),
static_cast<size_t>(1)));
}
}

View File

@ -29,6 +29,7 @@
#include <folly/FileUtil.h>
#include <folly/String.h>
#include <folly/json.h>
#include <folly/system/HardwareConcurrency.h>
#include "dwarfs/error.h"
#include "dwarfs/filesystem_v2.h"
@ -42,7 +43,7 @@ namespace dwarfs {
namespace po = boost::program_options;
int dwarfsck(int argc, char** argv) {
const size_t num_cpu = std::max(std::thread::hardware_concurrency(), 1u);
const size_t num_cpu = std::max(folly::hardware_concurrency(), 1u);
std::string log_level, input, export_metadata, image_offset;
size_t num_workers;

View File

@ -49,6 +49,7 @@
#include <folly/Conv.h>
#include <folly/FileUtil.h>
#include <folly/gen/String.h>
#include <folly/system/HardwareConcurrency.h>
#include <fmt/format.h>
@ -368,7 +369,7 @@ constexpr unsigned default_level = 7;
int mkdwarfs(int argc, char** argv) {
using namespace folly::gen;
const size_t num_cpu = std::max(std::thread::hardware_concurrency(), 1u);
const size_t num_cpu = std::max(folly::hardware_concurrency(), 1u);
block_manager::config cfg;
std::string path, output, memory_limit, script_arg, compression, header,