Skip to content

Commit 5907c45

Browse files
committed
debug FreeBSD
more traces to understand the issue use an alias instead of a function
1 parent c18374b commit 5907c45

File tree

3 files changed

+54
-18
lines changed

3 files changed

+54
-18
lines changed

lib/zstd.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ extern "C" {
111111
/*------ Version ------*/
112112
#define ZSTD_VERSION_MAJOR 1
113113
#define ZSTD_VERSION_MINOR 5
114-
#define ZSTD_VERSION_RELEASE 7
114+
#define ZSTD_VERSION_RELEASE 8
115115
#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
116116

117117
/*! ZSTD_versionNumber() :

programs/zstdcli.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,12 @@ static void printVersion(void)
686686
DISPLAYOUT("lz4 version %s\n", FIO_lz4Version());
687687
DISPLAYOUT("lzma version %s\n", FIO_lzmaVersion());
688688

689+
#ifdef ZSTD_MULTITHREAD
690+
DISPLAYOUT("supports Multithreading \n");
691+
#else
692+
DISPLAYOUT("single-thread operations only \n");
693+
#endif
694+
689695
/* posix support */
690696
#ifdef _POSIX_C_SOURCE
691697
DISPLAYOUT("_POSIX_C_SOURCE defined: %ldL\n", (long) _POSIX_C_SOURCE);
@@ -779,6 +785,11 @@ static int init_cLevel(void) {
779785
static unsigned init_nbWorkers(void) {
780786
#ifdef ZSTD_MULTITHREAD
781787
const char* const env = getenv(ENV_NBWORKERS);
788+
if (env==NULL) {
789+
DISPLAYLEVEL(1, "Failed Reading environment variable %s \n", ENV_NBWORKERS);
790+
} else {
791+
DISPLAYLEVEL(1, "Reading environment variable %s : %s \n", ENV_NBWORKERS, env);
792+
}
782793
if (env != NULL) {
783794
const char* ptr = env;
784795
if ((*ptr>='0') && (*ptr<='9')) {
@@ -793,6 +804,7 @@ static unsigned init_nbWorkers(void) {
793804
DISPLAYLEVEL(2, "Ignore environment variable setting %s=%s: not a valid unsigned value \n", ENV_NBWORKERS, env);
794805
}
795806

807+
DISPLAYLEVEL(1, "returning default nbThreads = %i \n", ZSTDCLI_NBTHREADS_DEFAULT);
796808
return ZSTDCLI_NBTHREADS_DEFAULT;
797809
#else
798810
return 1;
@@ -1336,7 +1348,7 @@ int main(int argCount, const char* argv[])
13361348

13371349
#ifdef ZSTD_MULTITHREAD
13381350
if ((nbWorkers==NBWORKERS_AUTOCPU) && (!singleThread)) {
1339-
/* automatically set # workers based on # of reported cpus */
1351+
/* automatically set # workers based on # of reported cpu cores */
13401352
if (defaultLogicalCores) {
13411353
nbWorkers = (unsigned)UTIL_countLogicalCores();
13421354
DISPLAYLEVEL(3, "Note: %d logical core(s) detected \n", nbWorkers);
@@ -1345,8 +1357,7 @@ int main(int argCount, const char* argv[])
13451357
DISPLAYLEVEL(3, "Note: %d physical core(s) detected \n", nbWorkers);
13461358
}
13471359
}
1348-
if (operation != zom_bench)
1349-
DISPLAYLEVEL(4, "Compressing with %u worker threads \n", nbWorkers);
1360+
DISPLAYLEVEL(1, "Compressing with %u worker threads \n", nbWorkers);
13501361
#else
13511362
(void)singleThread; (void)nbWorkers; (void)defaultLogicalCores;
13521363
#endif

tests/playTests.sh

+39-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
set -e # exit immediately on error
4-
# set -x # print commands before execution (debug)
4+
set -x # print commands before execution (debug)
55

66
unset ZSTD_CLEVEL
77
unset ZSTD_NBTHREADS
@@ -16,13 +16,15 @@ datagen() {
1616
"$DATAGEN_BIN" "$@"
1717
}
1818

19-
zstd() {
20-
if [ -z "$EXE_PREFIX" ]; then
21-
"$ZSTD_BIN" "$@"
22-
else
23-
"$EXE_PREFIX" "$ZSTD_BIN" "$@"
24-
fi
25-
}
19+
#zstd() {
20+
# if [ -z "$EXE_PREFIX" ]; then
21+
# "$ZSTD_BIN" "$@"
22+
# else
23+
# "$EXE_PREFIX" "$ZSTD_BIN" "$@"
24+
# fi
25+
#}
26+
27+
alias zstd="$EXE_PREFIX $ZSTD_BIN"
2628

2729
sudoZstd() {
2830
if [ -z "$EXE_PREFIX" ]; then
@@ -1563,17 +1565,40 @@ then
15631565
println "\n===> zstdmt environment variable tests "
15641566
echo "multifoo" >> mt_tmp
15651567
ZSTD_NBTHREADS=-3 zstd -f mt_tmp # negative value, warn and revert to default setting
1566-
ZSTD_NBTHREADS='' zstd -f mt_tmp # empty env var, warn and revert to default setting
1567-
ZSTD_NBTHREADS=- zstd -f mt_tmp # malformed env var, warn and revert to default setting
1568-
ZSTD_NBTHREADS=a zstd -f mt_tmp # malformed env var, warn and revert to default setting
1569-
ZSTD_NBTHREADS=+a zstd -f mt_tmp # malformed env var, warn and revert to default setting
1568+
ZSTD_NBTHREADS='' zstd -f mt_tmp # empty env var, warn and revert to default setting
1569+
ZSTD_NBTHREADS=- zstd -f mt_tmp # malformed env var, warn and revert to default setting
1570+
ZSTD_NBTHREADS=a zstd -f mt_tmp # malformed env var, warn and revert to default setting
1571+
ZSTD_NBTHREADS=+a zstd -f mt_tmp # malformed env var, warn and revert to default setting
15701572
ZSTD_NBTHREADS=3a7 zstd -f mt_tmp # malformed env var, warn and revert to default setting
15711573
ZSTD_NBTHREADS=50000000000 zstd -f mt_tmp # numeric value too large, warn and revert to default setting=
15721574
ZSTD_NBTHREADS=2 zstd -f mt_tmp # correct usage
15731575
ZSTD_NBTHREADS=1 zstd -f mt_tmp # correct usage: single worker
1574-
ZSTD_NBTHREADS=4 zstd -f mt_tmp -vv 2>&1 | grep "4 worker threads" # check message
1576+
1577+
1578+
# start of problematic test on FreeBSD; developping for testing and traces
1579+
zstd -vvvv --version
1580+
1581+
echo $0 # try to get shell name (note: not guaranteed)
1582+
1583+
zstd -T4 -f mt_tmp -vv # for comparison
1584+
1585+
ZSTD_NBTHREADS=4 zstd -f mt_tmp -vv
1586+
1587+
env ZSTD_NBTHREADS=4 zstd -f mt_tmp -vv
1588+
1589+
ZSTD_NBTHREADS=4 zstd -f mt_tmp -vv > mt_tmp_nbt4 2>&1
1590+
1591+
ls -las mt_tmp_nbt4
1592+
1593+
cat mt_tmp_nbt4
1594+
1595+
cat mt_tmp_nbt4 | $GREP "worker"
1596+
1597+
# The test below typically fails
1598+
ZSTD_NBTHREADS=4 zstd -f mt_tmp -vv 2>&1 | $GREP "4 worker threads" # check message
1599+
15751600
zstd -tq mt_tmp.zst
1576-
ZSTD_NBTHREADS=0 zstd -f mt_tmp -vv 2>&1 | grep "core(s) detected" # check core count autodetection is triggered
1601+
ZSTD_NBTHREADS=0 zstd -f mt_tmp -vv 2>&1 | $GREP "core(s) detected" # check core count autodetection is triggered
15771602
zstd -tq mt_tmp.zst
15781603
# temporary envvar changes in the above tests would actually persist in macos /bin/sh
15791604
unset ZSTD_NBTHREADS

0 commit comments

Comments
 (0)