Fix Delta2 decode handling when not compressing.

More debug statements and other minor changes.
This commit is contained in:
Moinak Ghosh 2012-12-24 23:21:02 +05:30
parent d597f0f05c
commit 063624d0d3
2 changed files with 16 additions and 6 deletions

View file

@ -27,7 +27,7 @@
* (3, 5, 7, 8) are tried to find the one that gives the maximum * (3, 5, 7, 8) are tried to find the one that gives the maximum
* reduction. A span length threshold in bytes is used. Byte spans * reduction. A span length threshold in bytes is used. Byte spans
* less than this threshold are ignored. * less than this threshold are ignored.
* Bytes are packed into integers in big-endian format. * Bytes are packed into integers in little-endian format.
* *
* After an optimal stride length has been identified the encoder * After an optimal stride length has been identified the encoder
* performs a delta run length encoding on the spans. Two types of * performs a delta run length encoding on the spans. Two types of
@ -71,7 +71,7 @@
#define MSB_SHIFT (56) #define MSB_SHIFT (56)
/* /*
* Delta2 algorithm processes data in chunks. The 4K size below is somewhat * Delta2 algorithm processes data in blocks. The 4K size below is somewhat
* adhoc but a couple of considerations were looked at: * adhoc but a couple of considerations were looked at:
* 1) Balance between number of headers and delta runs. Too small chunks * 1) Balance between number of headers and delta runs. Too small chunks
* will increase header counts for long delta runs spanning chunks. * will increase header counts for long delta runs spanning chunks.
@ -86,8 +86,8 @@
* and interpreted in little-endian order. * and interpreted in little-endian order.
*/ */
#if BYTE_ORDER == BIG_ENDIAN #if BYTE_ORDER == BIG_ENDIAN
#define HTONLL __bswap_64(x) #define HTONLL htonll
#define NTOHLL __bswap_64(x) #define NTOHLL ntohll
#else #else
#define HTONLL #define HTONLL
#define NTOHLL #define NTOHLL
@ -249,14 +249,14 @@ delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen
gtot2 += DELTA_HDR; gtot2 += DELTA_HDR;
/* /*
* If this ended into another table reset next scan * If this ended into another table reset next scan
* point to before the table. * point to beginning of the table.
*/ */
val = cnt - snum; val = cnt - snum;
} else { } else {
gtot2 += snum; gtot2 += snum;
/* /*
* If this ended into another table reset next scan * If this ended into another table reset next scan
* point to before the table. * point to beginning of the table.
*/ */
if (snum >= (MIN_THRESH>>1)) if (snum >= (MIN_THRESH>>1))
val = cnt - snum; val = cnt - snum;

10
main.c
View file

@ -247,6 +247,7 @@ preproc_compress(compress_func_ptr cmp_func, void *src, uint64_t srclen, void *d
*dstlen = _dstlen + 9; *dstlen = _dstlen + 9;
DEBUG_STAT_EN(fprintf(stderr, "Chunk compression speed %.3f MB/s\n", get_mb_s(srclen, strt, en))); DEBUG_STAT_EN(fprintf(stderr, "Chunk compression speed %.3f MB/s\n", get_mb_s(srclen, strt, en)));
} else { } else {
DEBUG_STAT_EN(fprintf(stderr, "Chunk did not compress.\n"));
memcpy(dest+1, src, srclen); memcpy(dest+1, src, srclen);
*dstlen = srclen + 1; *dstlen = srclen + 1;
result = 0; result = 0;
@ -274,10 +275,13 @@ preproc_decompress(compress_func_ptr dec_func, void *src, uint64_t srclen, void
DEBUG_STAT_EN(strt = get_wtime_millis()); DEBUG_STAT_EN(strt = get_wtime_millis());
result = dec_func(sorc, srclen, dst, dstlen, level, chdr, data); result = dec_func(sorc, srclen, dst, dstlen, level, chdr, data);
DEBUG_STAT_EN(en = get_wtime_millis()); DEBUG_STAT_EN(en = get_wtime_millis());
if (result < 0) return (result); if (result < 0) return (result);
DEBUG_STAT_EN(fprintf(stderr, "Chunk decompression speed %.3f MB/s\n", get_mb_s(srclen, strt, en))); DEBUG_STAT_EN(fprintf(stderr, "Chunk decompression speed %.3f MB/s\n", get_mb_s(srclen, strt, en)));
memcpy(src, dst, *dstlen); memcpy(src, dst, *dstlen);
srclen = *dstlen; srclen = *dstlen;
} else {
src = sorc;
} }
if (type & PREPROC_TYPE_DELTA2) { if (type & PREPROC_TYPE_DELTA2) {
@ -1253,8 +1257,14 @@ plain_compress:
compressed_chunk, &_chunksize, tdat->level, 0, tdat->data, compressed_chunk, &_chunksize, tdat->level, 0, tdat->data,
tdat->props); tdat->props);
} else { } else {
DEBUG_STAT_EN(double strt, en);
DEBUG_STAT_EN(strt = get_wtime_millis());
rv = tdat->compress(tdat->uncompressed_chunk, tdat->rbytes, rv = tdat->compress(tdat->uncompressed_chunk, tdat->rbytes,
compressed_chunk, &_chunksize, tdat->level, 0, tdat->data); compressed_chunk, &_chunksize, tdat->level, 0, tdat->data);
DEBUG_STAT_EN(en = get_wtime_millis());
DEBUG_STAT_EN(fprintf(stderr, "Chunk compression speed %.3f MB/s\n",
get_mb_s(_chunksize, strt, en)));
} }
} }