Skip to content

Commit

Permalink
Set lower bound for nbthreads default to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellerozenblit committed Dec 11, 2024
1 parent 2a8502e commit 08590d2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions programs/zstdcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
# define ZSTDCLI_CLEVEL_MAX 19 /* without using --ultra */
#endif

#ifndef ZSTDCLI_NBTHREADS_DEFAULT
#define ZSTDCLI_NBTHREADS_DEFAULT (UTIL_countLogicalCores() / 4 > 4 ? 4 : UTIL_countLogicalCores() / 4)
#endif

/*-************************************
* Dependencies
**************************************/
Expand Down Expand Up @@ -762,6 +758,9 @@ static int init_cLevel(void) {
#ifdef ZSTD_MULTITHREAD
static unsigned default_nbThreads(void) {
const char* const env = getenv(ENV_NBTHREADS);
unsigned nbthreads_default = UTIL_countLogicalCores() / 4;
if (nbthreads_default < 1) nbthreads_default = 1;
if (nbthreads_default > 4) nbthreads_default = 4;
if (env != NULL) {
const char* ptr = env;
if ((*ptr>='0') && (*ptr<='9')) {
Expand Down

0 comments on commit 08590d2

Please sign in to comment.