improved 4reps in ZSTD_compressBlock_lazy_generic
kSlotNew = 0
This commit is contained in:
+7
-7
@@ -1617,8 +1617,8 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
|
|||||||
if (depth==0) goto _storeSequence;
|
if (depth==0) goto _storeSequence;
|
||||||
} else {
|
} else {
|
||||||
size_t mlRep = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
|
size_t mlRep = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
|
||||||
int gain2 = (int)(mlRep * 3 /*- ZSTD_highbit((U32)i+1)*/);
|
int gain2 = (int)(mlRep * 3 /*- ZSTD_highbit((U32)i+1)*/ + (i==1));
|
||||||
int gain1 = (int)(matchLength*3 - /*ZSTD_highbit((U32)offset+1)*/ + 1);
|
int gain1 = (int)(matchLength*3 - /*ZSTD_highbit((U32)offset+1)*/ + 1 + (offset==1));
|
||||||
if (gain2 > gain1)
|
if (gain2 > gain1)
|
||||||
matchLength = mlRep, offset = i;
|
matchLength = mlRep, offset = i;
|
||||||
}
|
}
|
||||||
@@ -1642,10 +1642,10 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
|
|||||||
while (ip<ilimit) {
|
while (ip<ilimit) {
|
||||||
ip ++;
|
ip ++;
|
||||||
for (int i=0; i<ZSTD_REP_NUM; i++)
|
for (int i=0; i<ZSTD_REP_NUM; i++)
|
||||||
if ((offset >= ZSTD_REP_NUM) && (MEM_read32(ip) == MEM_read32(ip - rep[i]))) {
|
if (MEM_read32(ip) == MEM_read32(ip - rep[i])) {
|
||||||
size_t mlRep = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
|
size_t mlRep = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
|
||||||
int gain2 = (int)(mlRep * 3);
|
int gain2 = (int)(mlRep * 3);
|
||||||
int gain1 = (int)(matchLength*3 - ZSTD_highbit((U32)offset+1) + 1);
|
int gain1 = (int)(matchLength*3 - ZSTD_highbit((U32)offset+1) + 1 + (offset<ZSTD_REP_NUM));
|
||||||
if ((mlRep >= MINMATCH) && (gain2 > gain1))
|
if ((mlRep >= MINMATCH) && (gain2 > gain1))
|
||||||
matchLength = mlRep, offset = i, start = ip;
|
matchLength = mlRep, offset = i, start = ip;
|
||||||
}
|
}
|
||||||
@@ -1663,10 +1663,10 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx,
|
|||||||
if ((depth==2) && (ip<ilimit)) {
|
if ((depth==2) && (ip<ilimit)) {
|
||||||
ip ++;
|
ip ++;
|
||||||
for (int i=0; i<ZSTD_REP_NUM; i++)
|
for (int i=0; i<ZSTD_REP_NUM; i++)
|
||||||
if ((offset >= ZSTD_REP_NUM) && (MEM_read32(ip) == MEM_read32(ip - rep[i]))) {
|
if (MEM_read32(ip) == MEM_read32(ip - rep[i])) {
|
||||||
size_t ml2 = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
|
size_t ml2 = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
|
||||||
int gain2 = (int)(ml2 * 4);
|
int gain2 = (int)(ml2 * 4);
|
||||||
int gain1 = (int)(matchLength*4 - ZSTD_highbit((U32)offset+1) + 1);
|
int gain1 = (int)(matchLength*4 - ZSTD_highbit((U32)offset+1) + 1 + (offset<ZSTD_REP_NUM));
|
||||||
if ((ml2 >= MINMATCH) && (gain2 > gain1))
|
if ((ml2 >= MINMATCH) && (gain2 > gain1))
|
||||||
matchLength = ml2, offset = i, start = ip;
|
matchLength = ml2, offset = i, start = ip;
|
||||||
}
|
}
|
||||||
@@ -1693,7 +1693,7 @@ _storeSequence:
|
|||||||
{
|
{
|
||||||
#if ZSTD_REP_NUM == 4
|
#if ZSTD_REP_NUM == 4
|
||||||
if (offset >= ZSTD_REP_NUM) {
|
if (offset >= ZSTD_REP_NUM) {
|
||||||
#if 0
|
#if 1
|
||||||
rep[3] = rep[2];
|
rep[3] = rep[2];
|
||||||
rep[2] = rep[1];
|
rep[2] = rep[1];
|
||||||
rep[1] = rep[0];
|
rep[1] = rep[0];
|
||||||
|
|||||||
@@ -691,19 +691,26 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
|
|||||||
if (offset == 3) seqState->prevOffset[3] = seqState->prevOffset[2];
|
if (offset == 3) seqState->prevOffset[3] = seqState->prevOffset[2];
|
||||||
seqState->prevOffset[2] = seqState->prevOffset[1];
|
seqState->prevOffset[2] = seqState->prevOffset[1];
|
||||||
}
|
}
|
||||||
offset = temp;
|
|
||||||
seqState->prevOffset[1] = seqState->prevOffset[0];
|
seqState->prevOffset[1] = seqState->prevOffset[0];
|
||||||
seqState->prevOffset[0] = offset;
|
seqState->prevOffset[0] = offset = temp;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
offset = seqState->prevOffset[0];
|
offset = seqState->prevOffset[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
offset -= ZSTD_REP_MOVE;
|
offset -= ZSTD_REP_MOVE;
|
||||||
|
#if 1 // faster without kSlotNew
|
||||||
|
seqState->prevOffset[3] = seqState->prevOffset[2];
|
||||||
|
seqState->prevOffset[2] = seqState->prevOffset[1];
|
||||||
|
seqState->prevOffset[1] = seqState->prevOffset[0];
|
||||||
|
seqState->prevOffset[0] = offset;
|
||||||
|
#else
|
||||||
if (kSlotNew < 3) seqState->prevOffset[3] = seqState->prevOffset[2];
|
if (kSlotNew < 3) seqState->prevOffset[3] = seqState->prevOffset[2];
|
||||||
if (kSlotNew < 2) seqState->prevOffset[2] = seqState->prevOffset[1];
|
if (kSlotNew < 2) seqState->prevOffset[2] = seqState->prevOffset[1];
|
||||||
if (kSlotNew < 1) seqState->prevOffset[1] = seqState->prevOffset[0];
|
if (kSlotNew < 1) seqState->prevOffset[1] = seqState->prevOffset[0];
|
||||||
seqState->prevOffset[kSlotNew] = offset;
|
seqState->prevOffset[kSlotNew] = offset;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#else // ZSTD_REP_NUM == 1
|
#else // ZSTD_REP_NUM == 1
|
||||||
#if 0
|
#if 0
|
||||||
|
|||||||
+1
-1
@@ -71,7 +71,7 @@
|
|||||||
#else
|
#else
|
||||||
#define ZSTD_REP_NUM 1
|
#define ZSTD_REP_NUM 1
|
||||||
#define ZSTD_REP_INIT 2
|
#define ZSTD_REP_INIT 2
|
||||||
#define ZSTD_REP_MOVE 0//(ZSTD_REP_NUM-1)
|
#define ZSTD_REP_MOVE 0 //(ZSTD_REP_NUM-1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define KB *(1 <<10)
|
#define KB *(1 <<10)
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ DESTDIR?=
|
|||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
CPPFLAGS= -I../lib -DZSTD_VERSION=\"$(VERSION)\"
|
CPPFLAGS= -I../lib -DZSTD_VERSION=\"$(VERSION)\"
|
||||||
CFLAGS ?= -O3 # -falign-loops=32 # not always beneficial
|
CFLAGS ?= -O3 # -falign-loops=32 # not always beneficial
|
||||||
CFLAGS += -std=c99 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef
|
CFLAGS += -std=gnu99 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef
|
||||||
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
|
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
|
||||||
|
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
|
|||||||
+6
-6
@@ -52,12 +52,12 @@
|
|||||||
#include <stdio.h> /* fprintf, fopen, ftello64 */
|
#include <stdio.h> /* fprintf, fopen, ftello64 */
|
||||||
#include <sys/types.h> /* stat64 */
|
#include <sys/types.h> /* stat64 */
|
||||||
#include <sys/stat.h> /* stat64 */
|
#include <sys/stat.h> /* stat64 */
|
||||||
#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
|
#include <time.h> /* clock_t, clock, nanosleep, CLOCKS_PER_SEC */
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
#define mili_sleep(mili) Sleep(mili)
|
#define mili_sleep(mili) Sleep(mili)
|
||||||
#else
|
#else
|
||||||
#define mili_sleep(mili) usleep(mili*1000)
|
|
||||||
#include <sys/resource.h> /* setpriority */
|
#include <sys/resource.h> /* setpriority */
|
||||||
|
#define mili_sleep(mili) { struct timespec t; t.tv_sec=0; t.tv_nsec=mili*1000000L; nanosleep(&t, NULL); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* sleep : posix - windows - others */
|
/* sleep : posix - windows - others */
|
||||||
@@ -379,11 +379,11 @@ _findError:
|
|||||||
|
|
||||||
if (crcOrig == crcCheck)
|
if (crcOrig == crcCheck)
|
||||||
{
|
{
|
||||||
DISPLAYLEVEL(2, "%2i-%-17.17s :%10i ->%10i (%5.3f),%6.1f MB/s ,%6.1f MB/s \n", cLevel, displayName, (int)srcSize, (int)cSize, ratio, (double)srcSize / fastestC / 1000., (double)srcSize / fastestD / 1000.);
|
|
||||||
result->ratio = ratio;
|
result->ratio = ratio;
|
||||||
result->cSize = cSize;
|
result->cSize = cSize;
|
||||||
result->cSpeed = (double)srcSize / fastestC / 1000.;
|
result->cSpeed = (double)srcSize / 1000000. / (fastestC / CLOCKS_PER_SEC);
|
||||||
result->dSpeed = (double)srcSize / fastestD / 1000.;
|
result->dSpeed = (double)srcSize / 1000000. / (fastestD / CLOCKS_PER_SEC);
|
||||||
|
DISPLAYLEVEL(2, "%2i-%-17.17s :%10i ->%10i (%5.3f),%6.1f MB/s ,%6.1f MB/s \n", cLevel, displayName, (int)srcSize, (int)cSize, ratio, result->cSpeed, result->dSpeed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DISPLAYLEVEL(2, "%2i-\n", cLevel);
|
DISPLAYLEVEL(2, "%2i-\n", cLevel);
|
||||||
@@ -449,7 +449,7 @@ static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
|
|||||||
dictBuffer, dictBufferSize, &result);
|
dictBuffer, dictBufferSize, &result);
|
||||||
if (g_displayLevel == 1) {
|
if (g_displayLevel == 1) {
|
||||||
if (additionalParam)
|
if (additionalParam)
|
||||||
DISPLAY("%-3i%11i (%5.3f) %6.1f MB/s %6.1f MB/s %s (p=%d)\n", -l, (int)result.cSize, result.ratio, result.cSpeed, result.dSpeed, displayName, additionalParam);
|
DISPLAY("%-3i%11i (%5.3f) %6.1f MB/s %6.1f MB/s %s (param=%d)\n", -l, (int)result.cSize, result.ratio, result.cSpeed, result.dSpeed, displayName, additionalParam);
|
||||||
else
|
else
|
||||||
DISPLAY("%-3i%11i (%5.3f) %6.1f MB/s %6.1f MB/s %s\n", -l, (int)result.cSize, result.ratio, result.cSpeed, result.dSpeed, displayName);
|
DISPLAY("%-3i%11i (%5.3f) %6.1f MB/s %6.1f MB/s %s\n", -l, (int)result.cSize, result.ratio, result.cSpeed, result.dSpeed, displayName);
|
||||||
total.cSize += result.cSize;
|
total.cSize += result.cSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user