Fine tune transpose parameters.

Fix minor nits.
This commit is contained in:
Moinak Ghosh 2012-12-14 19:12:48 +05:30
parent b0f41c2888
commit a98778d62f
2 changed files with 16 additions and 6 deletions

View file

@ -45,6 +45,7 @@
* 64bit delta value * 64bit delta value
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <utils.h> #include <utils.h>
#include <transpose.h> #include <transpose.h>
#include "delta2.h" #include "delta2.h"
@ -66,6 +67,9 @@
// Minimum span length // Minimum span length
#define MIN_THRESH (50) #define MIN_THRESH (50)
#define TRANSP_THRESH (100)
#define TRANSP_BIT (128)
#define TRANSP_MASK (127)
int int
delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int rle_thresh) delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int rle_thresh)
@ -151,6 +155,11 @@ delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int
gtot2 = 0; gtot2 = 0;
DEBUG_STAT_EN(num_trans = 0); DEBUG_STAT_EN(num_trans = 0);
if (rle_thresh <= TRANSP_THRESH) {
tot = rle_thresh/2;
} else {
tot = TRANSP_THRESH;
}
vl2 = *((uint64_t *)pos); vl2 = *((uint64_t *)pos);
vl2 = htonll(vl2); vl2 = htonll(vl2);
vl2 >>= ((sizeof (vl2) - stride) << 3); vl2 >>= ((sizeof (vl2) - stride) << 3);
@ -166,12 +175,12 @@ delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int
if (gtot1 > 0) { if (gtot1 > 0) {
/* /*
* Encode previous literal run, if any. If the literal run * Encode previous literal run, if any. If the literal run
* has enough large sequences just below threshold, do a * has enough (90%+) large sequences just below threshold,
* matrix transpose on the range in the hope of achieving * do a matrix transpose on the range in the hope of achieving
* a better compression ratio. * a better compression ratio.
*/ */
if (gtot2 >= ((gtot1 >> 1) + (gtot1 >> 2) + (gtot1 >> 3))) { if (gtot2 >= ((gtot1 >> 1) + (gtot1 >> 2) + (gtot1 >> 3))) {
*pos2 = stride | 128; *pos2 = stride | TRANSP_BIT;
pos2++; pos2++;
*((uint64_t *)pos2) = htonll(gtot1); *((uint64_t *)pos2) = htonll(gtot1);
pos2 += sizeof (uint64_t); pos2 += sizeof (uint64_t);
@ -201,7 +210,7 @@ delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int
pos1 = pos2 + LIT_HDR; pos1 = pos2 + LIT_HDR;
} else { } else {
gtot1 += snum; gtot1 += snum;
if (snum >= 50) if (snum >= tot)
gtot2 += snum; gtot2 += snum;
} }
snum = 0; snum = 0;
@ -295,12 +304,12 @@ delta2_decode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen)
pos1 += rcnt; pos1 += rcnt;
out += rcnt; out += rcnt;
} else if (*pos & 128) { } else if (*pos & TRANSP_BIT) {
int stride; int stride;
/* /*
* Copy over literal run of transposed bytes and inverse-transpose. * Copy over literal run of transposed bytes and inverse-transpose.
*/ */
stride = (*pos & 127); stride = (*pos & TRANSP_MASK);
pos++; pos++;
rcnt = ntohll(*((uint64_t *)pos)); rcnt = ntohll(*((uint64_t *)pos));
pos += sizeof (rcnt); pos += sizeof (rcnt);

1
main.c
View file

@ -197,6 +197,7 @@ preproc_compress(compress_func_ptr cmp_func, void *src, uint64_t srclen, void *d
uchar_t *dest = (uchar_t *)dst, type = 0; uchar_t *dest = (uchar_t *)dst, type = 0;
int64_t result, _dstlen; int64_t result, _dstlen;
_dstlen = *dstlen;
if (lzp_preprocess) { if (lzp_preprocess) {
int hashsize; int hashsize;