mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-10 21:10:02 -04:00
refactor: provider hardware_concurrency wrapper
This commit is contained in:
parent
9c8fd29ec2
commit
bd862d1e2a
@ -82,4 +82,6 @@ void ensure_binary_mode(std::ostream& os);
|
|||||||
std::string exception_str(std::exception const& e);
|
std::string exception_str(std::exception const& e);
|
||||||
std::string exception_str(std::exception_ptr const& e);
|
std::string exception_str(std::exception_ptr const& e);
|
||||||
|
|
||||||
|
unsigned int hardware_concurrency() noexcept;
|
||||||
|
|
||||||
} // namespace dwarfs
|
} // namespace dwarfs
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#include <folly/container/EvictingCacheMap.h>
|
#include <folly/container/EvictingCacheMap.h>
|
||||||
#include <folly/container/F14Map.h>
|
#include <folly/container/F14Map.h>
|
||||||
#include <folly/stats/Histogram.h>
|
#include <folly/stats/Histogram.h>
|
||||||
#include <folly/system/HardwareConcurrency.h>
|
|
||||||
#include <folly/system/ThreadName.h>
|
#include <folly/system/ThreadName.h>
|
||||||
|
|
||||||
#include <dwarfs/block_cache.h>
|
#include <dwarfs/block_cache.h>
|
||||||
@ -51,6 +50,7 @@
|
|||||||
#include <dwarfs/mmif.h>
|
#include <dwarfs/mmif.h>
|
||||||
#include <dwarfs/options.h>
|
#include <dwarfs/options.h>
|
||||||
#include <dwarfs/performance_monitor.h>
|
#include <dwarfs/performance_monitor.h>
|
||||||
|
#include <dwarfs/util.h>
|
||||||
|
|
||||||
namespace dwarfs {
|
namespace dwarfs {
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ class block_cache_ final : public block_cache::impl {
|
|||||||
wg_ = internal::worker_group(lgr, os_, "blkcache",
|
wg_ = internal::worker_group(lgr, os_, "blkcache",
|
||||||
std::max(options.num_workers > 0
|
std::max(options.num_workers > 0
|
||||||
? options.num_workers
|
? options.num_workers
|
||||||
: folly::hardware_concurrency(),
|
: hardware_concurrency(),
|
||||||
static_cast<size_t>(1)));
|
static_cast<size_t>(1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
#include <folly/String.h>
|
#include <folly/String.h>
|
||||||
#include <folly/portability/Windows.h>
|
#include <folly/portability/Windows.h>
|
||||||
#include <folly/system/HardwareConcurrency.h>
|
|
||||||
#include <folly/system/ThreadName.h>
|
#include <folly/system/ThreadName.h>
|
||||||
|
|
||||||
#include <dwarfs/error.h>
|
#include <dwarfs/error.h>
|
||||||
@ -65,7 +64,7 @@ class basic_worker_group final : public worker_group::impl, private Policy {
|
|||||||
, pending_(0)
|
, pending_(0)
|
||||||
, max_queue_len_(max_queue_len) {
|
, max_queue_len_(max_queue_len) {
|
||||||
if (num_workers < 1) {
|
if (num_workers < 1) {
|
||||||
num_workers = std::max(folly::hardware_concurrency(), 1u);
|
num_workers = std::max(hardware_concurrency(), 1u);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!group_name) {
|
if (!group_name) {
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <folly/String.h>
|
#include <folly/String.h>
|
||||||
#include <folly/portability/Fcntl.h>
|
#include <folly/portability/Fcntl.h>
|
||||||
#include <folly/portability/Windows.h>
|
#include <folly/portability/Windows.h>
|
||||||
|
#include <folly/system/HardwareConcurrency.h>
|
||||||
|
|
||||||
#include <dwarfs/error.h>
|
#include <dwarfs/error.h>
|
||||||
#include <dwarfs/options.h>
|
#include <dwarfs/options.h>
|
||||||
@ -386,4 +387,8 @@ std::string exception_str(std::exception_ptr const& e) {
|
|||||||
return folly::exceptionStr(e).toStdString();
|
return folly::exceptionStr(e).toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int hardware_concurrency() noexcept {
|
||||||
|
return folly::hardware_concurrency();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dwarfs
|
} // namespace dwarfs
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <folly/portability/Unistd.h>
|
#include <folly/portability/Unistd.h>
|
||||||
#include <folly/system/HardwareConcurrency.h>
|
|
||||||
|
|
||||||
#include <dwarfs/checksum.h>
|
#include <dwarfs/checksum.h>
|
||||||
#include <dwarfs/error.h>
|
#include <dwarfs/error.h>
|
||||||
@ -161,7 +160,7 @@ void do_checksum(logger& lgr, filesystem_v2& fs, iolayer const& iol,
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int dwarfsck_main(int argc, sys_char** argv, iolayer const& iol) {
|
int dwarfsck_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||||
const size_t num_cpu = std::max(folly::hardware_concurrency(), 1u);
|
const size_t num_cpu = std::max(hardware_concurrency(), 1u);
|
||||||
|
|
||||||
auto algo_list = checksum::available_algorithms();
|
auto algo_list = checksum::available_algorithms();
|
||||||
auto checksum_desc = fmt::format("print checksums for all files ({})",
|
auto checksum_desc = fmt::format("print checksums for all files ({})",
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
#include <folly/String.h>
|
#include <folly/String.h>
|
||||||
#include <folly/container/Enumerate.h>
|
#include <folly/container/Enumerate.h>
|
||||||
#include <folly/portability/SysStat.h>
|
#include <folly/portability/SysStat.h>
|
||||||
#include <folly/system/HardwareConcurrency.h>
|
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
#if FMT_VERSION >= 110000
|
#if FMT_VERSION >= 110000
|
||||||
@ -374,7 +373,7 @@ void validate(boost::any& v, std::vector<std::string> const& values,
|
|||||||
int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
const size_t num_cpu = std::max(folly::hardware_concurrency(), 1u);
|
const size_t num_cpu = std::max(hardware_concurrency(), 1u);
|
||||||
static constexpr size_t const kDefaultMaxActiveBlocks{1};
|
static constexpr size_t const kDefaultMaxActiveBlocks{1};
|
||||||
static constexpr size_t const kDefaultBloomFilterSize{4};
|
static constexpr size_t const kDefaultBloomFilterSize{4};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user