mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-15 15:26:19 -04:00
chore: add ability to override hardware concurrency from environment
This commit is contained in:
parent
9a87749358
commit
7a386ee443
@ -361,6 +361,8 @@ if [[ "-$BUILD_TYPE-" == *-static-* ]]; then
|
|||||||
|
|
||||||
if [[ -n "$CROSS_ARCH" ]]; then
|
if [[ -n "$CROSS_ARCH" ]]; then
|
||||||
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=$_MARCH -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-$_MARCH -DFOLLY_HAVE_UNALIGNED_ACCESS=OFF -DFOLLY_HAVE_WEAK_SYMBOLS=ON -DFOLLY_HAVE_LINUX_VDSO=OFF -DFOLLY_HAVE_WCHAR_SUPPORT=OFF -DHAVE_VSNPRINTF_ERRORS=OFF"
|
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=$_MARCH -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-$_MARCH -DFOLLY_HAVE_UNALIGNED_ACCESS=OFF -DFOLLY_HAVE_WEAK_SYMBOLS=ON -DFOLLY_HAVE_LINUX_VDSO=OFF -DFOLLY_HAVE_WCHAR_SUPPORT=OFF -DHAVE_VSNPRINTF_ERRORS=OFF"
|
||||||
|
# Limit emulated parallelism to 4 threads, otherwise the slowdown is substantial
|
||||||
|
export DWARFS_OVERRIDE_HARDWARE_CONCURRENCY=4
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -424,7 +424,14 @@ std::string exception_str(std::exception_ptr const& e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int hardware_concurrency() noexcept {
|
unsigned int hardware_concurrency() noexcept {
|
||||||
return folly::hardware_concurrency();
|
static auto const env = [] {
|
||||||
|
std::optional<int> concurrency;
|
||||||
|
if (auto env = std::getenv("DWARFS_OVERRIDE_HARDWARE_CONCURRENCY")) {
|
||||||
|
concurrency = try_to<int>(env);
|
||||||
|
}
|
||||||
|
return concurrency;
|
||||||
|
}();
|
||||||
|
return env.value_or(folly::hardware_concurrency());
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_current_umask() {
|
int get_current_umask() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user