]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
minor fixes
authorYann Collet <cyan@fb.com>
Sun, 1 Jan 2017 23:49:42 +0000 (00:49 +0100)
committerYann Collet <cyan@fb.com>
Sun, 1 Jan 2017 23:49:42 +0000 (00:49 +0100)
lib/compress/zstdmt_compress.c
lib/zstd.h
programs/bench.c

index b9cc81f67183d7650dcf9b07d11d3cab2c9ae0fa..294ce86d4f4af075e4e8e2d38442c2c59545fb91 100644 (file)
@@ -123,12 +123,12 @@ void ZSTDMT_compressFrame(void* jobDescription)
 {
     DEBUGLOG(5, "Entering ZSTDMT_compressFrame() ");
     ZSTDMT_jobDescription* const job = (ZSTDMT_jobDescription*)jobDescription;
-    DEBUGLOG(5, "compressing %u bytes with ZSTD_compressCCtx : ", (unsigned)job->srcSize);
+    DEBUGLOG(5, "compressing %u bytes from frame %u with ZSTD_compressCCtx : ", (unsigned)job->srcSize, job->jobCompleted);
     job->cSize = ZSTD_compressCCtx(job->cctx, job->dstBuff.start, job->dstBuff.size, job->srcStart, job->srcSize, job->compressionLevel);
     DEBUGLOG(5, "compressed to %u bytes  ", (unsigned)job->cSize);
-    job->jobCompleted = 1;
     DEBUGLOG(5, "sending jobCompleted signal");
     pthread_mutex_lock(job->jobCompleted_mutex);
+    job->jobCompleted = 1;
     pthread_cond_signal(job->jobCompleted_cond);
     pthread_mutex_unlock(job->jobCompleted_mutex);
     DEBUGLOG(5, "ZSTDMT_compressFrame completed");
@@ -215,6 +215,7 @@ size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* mtctx)  /* incompleted ! */
     ZSTDMT_freeBufferPool(mtctx->buffPool);
     ZSTDMT_freeCCtxPool(mtctx->cctxPool);
     pthread_mutex_destroy(&mtctx->jobCompleted_mutex);
+    pthread_cond_destroy(&mtctx->jobCompleted_cond);
     free(mtctx);
     return 0;
 }
index 333feff7da1462a845fc7b7054d0aa6131c5ea80..55cc466d70377505a39eb70663123ec4618225c9 100644 (file)
@@ -369,9 +369,9 @@ typedef struct {
 } ZSTD_compressionParameters;
 
 typedef struct {
-    unsigned contentSizeFlag; /**< 1: content size will be in frame header (if known). */
-    unsigned checksumFlag;    /**< 1: will generate a 22-bits checksum at end of frame, to be used for error detection by decompressor */
-    unsigned noDictIDFlag;    /**< 1: no dict ID will be saved into frame header (if dictionary compression) */
+    unsigned contentSizeFlag; /**< 1: content size will be in frame header (when known) */
+    unsigned checksumFlag;    /**< 1: generate a 32-bits checksum at end of frame, for error detection */
+    unsigned noDictIDFlag;    /**< 1: no dictID will be saved into frame header (if dictionary compression) */
 } ZSTD_frameParameters;
 
 typedef struct {
index c718e2199ade7f0770750d790c91e112e80661df..e846e9ef3a63339ecae99de318aa07339c0d65c7 100644 (file)
@@ -91,12 +91,12 @@ static clock_t g_time = 0;
 /* *************************************
 *  Time
 ***************************************/
-/* for posix only - proper detection macros to setup */
+/* for posix only - needs proper detection macros to setup */
 #include <unistd.h>
 #include <sys/times.h>
 
 typedef unsigned long long clock_us_t;
-static clock_us_t BMK_clockMicroSec()
+static clock_us_t BMK_clockMicroSec(void)
 {
    static clock_t _ticksPerSecond = 0;
    if (_ticksPerSecond <= 0) _ticksPerSecond = sysconf(_SC_CLK_TCK);
@@ -235,7 +235,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
     /* Bench */
     {   U64 fastestC = (U64)(-1LL), fastestD = (U64)(-1LL);
         U64 const crcOrig = g_decodeOnly ? 0 : XXH64(srcBuffer, srcSize, 0);
-        UTIL_time_t coolTime;
+        clock_us_t coolTime = BMK_clockMicroSec();
         U64 const maxTime = (g_nbSeconds * TIMELOOP_MICROSEC) + 1;
         U64 totalCTime=0, totalDTime=0;
         U32 cCompleted=g_decodeOnly, dCompleted=0;
@@ -245,15 +245,14 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
 
         ZSTDMT_CCtx* const mtcctx = ZSTDMT_createCCtx(g_nbThreads);
 
-        UTIL_getTime(&coolTime);
         DISPLAYLEVEL(2, "\r%79s\r", "");
         while (!cCompleted || !dCompleted) {
 
             /* overheat protection */
-            if (UTIL_clockSpanMicro(coolTime, ticksPerSecond) > ACTIVEPERIOD_MICROSEC) {
+            if (BMK_clockMicroSec() - coolTime > ACTIVEPERIOD_MICROSEC) {
                 DISPLAYLEVEL(2, "\rcooling down ...    \r");
                 UTIL_sleep(COOLPERIOD_SEC);
-                UTIL_getTime(&coolTime);
+                coolTime = BMK_clockMicroSec();
             }
 
             if (!g_decodeOnly) {