Use adapt2 as default compression in archive mode.

Add more filter auto-selection by compression level in archive mode.
Replace odd stride lengths in Delta2 with standard numeric type lengths and improve performance.
This commit is contained in:
Moinak Ghosh 2013-12-05 22:20:01 +05:30
parent 316d5aa4a8
commit 36ed5d5a78
4 changed files with 42 additions and 6 deletions

View file

@ -302,7 +302,7 @@ $(PJPGOBJS): $(PJPGSRCS) $(PJPGHDRS)
$(VEC_FLAGS) -DBUILD_LIB $(COMMON_CPPFLAGS_cpp) $(@:.o=.cpp) -o $@ $(VEC_FLAGS) -DBUILD_LIB $(COMMON_CPPFLAGS_cpp) $(@:.o=.cpp) -o $@
$(DISPACKOBJS): $(DISPACKSRCS) $(DISPACKHDRS) $(DISPACKOBJS): $(DISPACKSRCS) $(DISPACKHDRS)
$(COMPILE_cpp) $(COMMON_VEC_FLAGS) @SSE_OPT_FLAGS@ -O2 -fsched-spec-load \ $(COMPILE_cpp) $(COMMON_VEC_FLAGS) $(DEBUG_STATS_CPPFLAGS) @SSE_OPT_FLAGS@ -O2 -fsched-spec-load \
-Wno-variadic-macros $(VEC_FLAGS) $(COMMON_CPPFLAGS_cpp) $(@:.o=.cpp) -o $@ -Wno-variadic-macros $(VEC_FLAGS) $(COMMON_CPPFLAGS_cpp) $(@:.o=.cpp) -o $@
$(SKEIN_BLOCK_OBJ): $(SKEIN_BLOCK_SRC) $(SKEIN_BLOCK_OBJ): $(SKEIN_BLOCK_SRC)

View file

@ -91,10 +91,11 @@
/* /*
* Stride values to be checked. As of this implementation strides only * Stride values to be checked. As of this implementation strides only
* upto 8 bytes (uint64_t) are supported. * upto 8 bytes (uint64_t) are supported and common type lengths only
* are checked.
*/ */
#define NSTRIDES 4 #define NSTRIDES 3
static uchar_t strides[NSTRIDES] = {3, 5, 7, 8}; static uchar_t strides[NSTRIDES] = {2, 4, 8};
static int delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, static int delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen,

View file

@ -29,6 +29,9 @@
#include <string.h> #include <string.h>
#include <malloc.h> #include <malloc.h>
#include <assert.h> #include <assert.h>
#include <iostream>
using namespace std;
/* Version history: /* Version history:
* *
@ -944,10 +947,16 @@ dispack_encode(uchar_t *from, uint64_t fromlen, uchar_t *to, uint64_t *dstlen)
{ {
uchar_t *pos, *hdr, type, *pos_to, *to_last; uchar_t *pos, *hdr, type, *pos_to, *to_last;
uint64_t len; uint64_t len;
#ifdef DEBUG_STATS
double strt, en;
#endif
if (fromlen < DISFILTER_BLOCK) if (fromlen < DISFILTER_BLOCK)
return (-1); return (-1);
#ifdef DEBUG_STATS
strt = get_wtime_millis();
#endif
pos = from; pos = from;
len = fromlen; len = fromlen;
pos_to = to; pos_to = to;
@ -1009,9 +1018,19 @@ dispack_encode(uchar_t *from, uint64_t fromlen, uchar_t *to, uint64_t *dstlen)
len -= sz; len -= sz;
} }
*dstlen = pos_to - to; *dstlen = pos_to - to;
#ifdef DEBUG_STATS
en = get_wtime_millis();
cerr << "Dispack: Processed at " << get_mb_s(fromlen, strt, en) << " MB/s" << endl;
#endif
if ((fromlen - *dstlen) < DIS_MIN_REDUCE) { if ((fromlen - *dstlen) < DIS_MIN_REDUCE) {
#ifdef DEBUG_STATS
cerr << "Dispack: Failed, reduction too less" << endl;
#endif
return (-1); return (-1);
} }
#ifdef DEBUG_STATS
cerr << "Dispack: srclen: " << fromlen << ", dstlen: " << *dstlen << endl;
#endif
return (0); return (0);
} }

View file

@ -2946,6 +2946,7 @@ init_pc_context(pc_ctx_t *pctx, int argc, char *argv[])
case 'a': case 'a':
pctx->archive_mode = 1; pctx->archive_mode = 1;
pctx->do_compress = 1;
break; break;
case 'v': case 'v':
@ -2978,6 +2979,19 @@ init_pc_context(pc_ctx_t *pctx, int argc, char *argv[])
return (2); return (2);
} }
if (pctx->archive_mode && pctx->do_uncompress) {
log_msg(LOG_ERR, 0, "'-a' flag is only for archive creation.");
return (1);
}
/*
* Default compression algorithm during archiving is Adaptive2.
*/
if (pctx->archive_mode && pctx->algo == NULL) {
pctx->algo = "adapt2";
init_algo(pctx, pctx->algo, 1);
}
if (pctx->level == -1 && pctx->do_compress) { if (pctx->level == -1 && pctx->do_compress) {
if (memcmp(pctx->algo, "lz4", 3) == 0) { if (memcmp(pctx->algo, "lz4", 3) == 0) {
pctx->level = 1; pctx->level = 1;
@ -3204,16 +3218,18 @@ init_pc_context(pc_ctx_t *pctx, int argc, char *argv[])
} }
/* /*
* Selectively enable filters while compressing. * Selectively enable filters while archiving, depending on compression level.
*/ */
if (pctx->archive_mode) { if (pctx->archive_mode) {
struct filter_flags ff; struct filter_flags ff;
ff.enable_packjpg = 0; ff.enable_packjpg = 0;
if (pctx->level > 9) ff.enable_packjpg = 1; if (pctx->level > 10) ff.enable_packjpg = 1;
init_filters(&ff); init_filters(&ff);
pctx->enable_packjpg = ff.enable_packjpg; pctx->enable_packjpg = ff.enable_packjpg;
if (pctx->level > 8) pctx->dispack_preprocess = 1; if (pctx->level > 8) pctx->dispack_preprocess = 1;
if (pctx->level > 4) pctx->enable_delta2_encode = 1;
if (pctx->level > 9) pctx->lzp_preprocess = 1;
} }
if (pctx->lzp_preprocess || pctx->enable_delta2_encode || pctx->dispack_preprocess) { if (pctx->lzp_preprocess || pctx->enable_delta2_encode || pctx->dispack_preprocess) {
pctx->preprocess_mode = 1; pctx->preprocess_mode = 1;