XZ Utils 5.3.4alpha
|
Detection of available hardware resources. More...
#include "private.h"
Functions | |
void | hardware_threads_set (uint32_t n) |
Set the maximum number of worker threads. More... | |
uint32_t | hardware_threads_get (void) |
Get the maximum number of worker threads. More... | |
bool | hardware_threads_is_mt (void) |
void | hardware_memlimit_set (uint64_t new_memlimit, bool set_compress, bool set_decompress, bool set_mtdec, bool is_percentage) |
uint64_t | hardware_memlimit_get (enum operation_mode mode) |
uint64_t | hardware_memlimit_mtenc_get (void) |
bool | hardware_memlimit_mtenc_is_default (void) |
uint64_t | hardware_memlimit_mtdec_get (void) |
static void | memlimit_show (const char *str, size_t str_columns, uint64_t value) |
Helper for hardware_memlimit_show() to print one human-readable info line. More... | |
void | hardware_memlimit_show (void) |
Display the amount of RAM and memory usage limits and exit. More... | |
void | hardware_init (void) |
Variables | |
static uint32_t | threads_max = 1 |
static bool | threads_are_automatic = false |
static uint64_t | memlimit_compress = 0 |
Memory usage limit for compression. More... | |
static uint64_t | memlimit_decompress = 0 |
Memory usage limit for decompression. More... | |
static uint64_t | memlimit_mt_default |
static uint64_t | memlimit_mtdec |
static uint64_t | total_ram |
Total amount of physical RAM. More... | |
Detection of available hardware resources.
void hardware_threads_set | ( | uint32_t | n | ) |
Set the maximum number of worker threads.
References lzma_cputhreads(), threads_are_automatic, and threads_max.
uint32_t hardware_threads_get | ( | void | ) |
Get the maximum number of worker threads.
References threads_max.
bool hardware_threads_is_mt | ( | void | ) |
Returns true if multithreaded mode should be used for .xz compression. This can be true even if the number of threads is one.
References threads_are_automatic, and threads_max.
void hardware_memlimit_set | ( | uint64_t | new_memlimit, |
bool | set_compress, | ||
bool | set_decompress, | ||
bool | set_mtdec, | ||
bool | is_percentage | ||
) |
Set the memory usage limit. There are separate limits for compression, decompression (also includes –list), and multithreaded decompression. Any combination of these can be set with a single call to this function. Zero indicates resetting the limit back to the defaults. The limit can also be set as a percentage of installed RAM; the percentage must be in the range [1, 100].
uint64_t hardware_memlimit_get | ( | enum operation_mode | mode | ) |
Get the current memory usage limit for compression or decompression. This is a hard limit that will not be exceeded. This is obeyed in both single-threaded and multithreaded modes.
Referenced by hardware_memlimit_mtenc_get(), and message_mem_needed().
uint64_t hardware_memlimit_mtenc_get | ( | void | ) |
This returns a system-specific default value if all of the following conditions are true:
Otherwise this is identical to hardware_memlimit_get(MODE_COMPRESS).
The idea is to keep automatic thread count reasonable so that too high memory usage is avoided and, with 32-bit xz, running out of address space is avoided.
References hardware_memlimit_get(), memlimit_compress, memlimit_mt_default, and threads_are_automatic.
bool hardware_memlimit_mtenc_is_default | ( | void | ) |
Returns true if the value returned by hardware_memlimit_mtenc_get() is a system-specific default value. coder.c uses this to ignore the default memlimit in case it's too small even for a single thread in multithreaded mode. This way the default limit will never make xz fail or affect the compressed output; it will only make xz reduce the number of threads.
References memlimit_compress, and threads_are_automatic.
uint64_t hardware_memlimit_mtdec_get | ( | void | ) |
Get the current memory usage limit for multithreaded decompression. This is only used to reduce the number of threads. This limit can be exceeded if the number of threads are reduce to one. Then the value from hardware_memlimit_get() will be honored like in single-threaded mode.
References memlimit_decompress, memlimit_mt_default, and memlimit_mtdec.
|
static |
Helper for hardware_memlimit_show() to print one human-readable info line.
References fw.
void hardware_memlimit_show | ( | void | ) |
Display the amount of RAM and memory usage limits and exit.
References lzma_cputhreads().
void hardware_init | ( | void | ) |
Initialize some hardware-specific variables, which are needed by other hardware_* functions.
References lzma_physmem(), memlimit_mt_default, and total_ram.
|
static |
Maximum number of worker threads. This can be set with the –threads=NUM command line option.
Referenced by hardware_threads_get(), hardware_threads_is_mt(), and hardware_threads_set().
|
static |
True when the number of threads is automatically determined based on the available hardware threads.
Referenced by hardware_memlimit_mtenc_get(), hardware_memlimit_mtenc_is_default(), hardware_threads_is_mt(), and hardware_threads_set().
|
static |
Memory usage limit for compression.
Referenced by hardware_memlimit_mtenc_get(), and hardware_memlimit_mtenc_is_default().
|
static |
Memory usage limit for decompression.
Referenced by hardware_memlimit_mtdec_get().
|
static |
Default memory usage for multithreaded modes:
This value is caluclated in hardware_init() and cannot be changed later.
Referenced by hardware_init(), hardware_memlimit_mtdec_get(), and hardware_memlimit_mtenc_get().
|
static |
Memory usage limit for multithreaded decompression. This is a soft limit: if reducing the number of threads to one isn't enough to keep memory usage below this limit, then one thread is used and this limit is ignored. memlimit_decompress is still obeyed.
This can be set with –memlimit-mt-decompress. The default value for this is memlimit_mt_default.
Referenced by hardware_memlimit_mtdec_get().
|
static |
Total amount of physical RAM.
Referenced by hardware_init().