From fe18afbcf41d3a10c73659625aac0d0d0ffe1be1 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Wed, 7 Aug 2013 22:03:52 +0530 Subject: [PATCH] Use wrapper script to set paths when launching pcompress from build directory. Use smaller max block size when doing global dedupe. Fix init of executable name. --- Makefile.in | 5 ++++- pcompress.c | 6 ++++++ pcompress.h | 3 ++- rabin/rabin_dedup.c | 4 +++- rabin/rabin_dedup.h | 3 ++- utils/pcompress.sh | 8 ++++++++ 6 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 utils/pcompress.sh diff --git a/Makefile.in b/Makefile.in index 27225cb..6958c37 100644 --- a/Makefile.in +++ b/Makefile.in @@ -342,6 +342,9 @@ $(LIB): $(OBJS) $(PROG): $(LIB) $(PROGOBJS) $(LINK.PROG) -o $@ $(PROGOBJS) $(LDLIBS) -L. -l$(LINKLIB) + cp $@ buildtmp + cat utils/pcompress.sh | sed "s##`pwd`#" > pcompress + chmod +x pcompress test: all (cd test; ulimit -c unlimited; sh ./run_test.sh $(TESTSUITE) ) 2>&1 | tee test.log @@ -358,7 +361,7 @@ distclean: clean install: $(PROG) @mkdir -p $(DESTDIR)$(PREFIX)/bin @chmod 0755 $(DESTDIR)$(PREFIX)/bin - @cp $(PROG) $(DESTDIR)$(PREFIX)/bin + @cp buildtmp/$(PROG) $(DESTDIR)$(PREFIX)/bin @chmod 0555 $(DESTDIR)$(PREFIX)/bin/$(PROG) @mkdir -p $(DESTDIR)$(PREFIX)/lib diff --git a/pcompress.c b/pcompress.c index c4ced3a..edfc6a2 100644 --- a/pcompress.c +++ b/pcompress.c @@ -2531,6 +2531,7 @@ create_pc_context(void) init_pcompress(); memset(ctx, 0, sizeof (pc_ctx_t)); + ctx->exec_name = (char *)malloc(NAME_MAX); ctx->hide_mem_stats = 1; ctx->hide_cmp_stats = 1; ctx->enable_rabin_split = 1; @@ -2574,11 +2575,16 @@ int DLL_EXPORT init_pc_context(pc_ctx_t *pctx, int argc, char *argv[]) { int opt, num_rem, err, my_optind; + char *pos; pctx->level = 6; err = 0; pctx->keylen = DEFAULT_KEYLEN; pctx->chunksize = DEFAULT_CHUNKSIZE; + pos = argv[0] + strlen(argv[0]); + while (*pos != '/' && pos > argv[0]) pos--; + if (*pos == '/') pos++; + strcpy(pctx->exec_name, pos); pthread_mutex_lock(&opt_parse); while ((opt = getopt(argc, argv, "dc:s:l:pt:MCDGEe:w:rLPS:B:Fk:")) != -1) { diff --git a/pcompress.h b/pcompress.h index 8d70101..c26797a 100644 --- a/pcompress.h +++ b/pcompress.h @@ -200,7 +200,8 @@ typedef struct pc_ctx { unsigned int chunk_num; uint64_t largest_chunk, smallest_chunk, avg_chunk; uint64_t chunksize; - const char *exec_name, *algo, *filename, *to_filename; + const char *algo, *filename, *to_filename; + char *exec_name; int do_compress, level; int do_uncompress; int cksum_bytes, mac_bytes; diff --git a/rabin/rabin_dedup.c b/rabin/rabin_dedup.c index 51fd44e..56290b9 100755 --- a/rabin/rabin_dedup.c +++ b/rabin/rabin_dedup.c @@ -284,8 +284,10 @@ create_dedupe_context(uint64_t chunksize, uint64_t real_chunksize, int rab_blk_s ctx->deltac_min_distance = props->deltac_min_distance; ctx->pagesize = sysconf(_SC_PAGE_SIZE); ctx->similarity_cksums = NULL; - if (arc) + if (arc) { arc->pagesize = ctx->pagesize; + ctx->rabin_poly_max_block_size = RAB_POLY_MAX_BLOCK_SIZE_GLOBAL; + } /* * Scale down similarity percentage based on avg block size unless user specified diff --git a/rabin/rabin_dedup.h b/rabin/rabin_dedup.h index 323f9db..a58e90a 100644 --- a/rabin/rabin_dedup.h +++ b/rabin/rabin_dedup.h @@ -80,7 +80,8 @@ #define RAB_POLYNOMIAL_WIN_SIZE 16 #define RAB_POLYNOMIAL_MIN_WIN_SIZE 8 #define RAB_POLYNOMIAL_MAX_WIN_SIZE 64 -#define RAB_POLYNOMIAL_MAX_BLOCK_SIZE (64 * 1024) +#define RAB_POLYNOMIAL_MAX_BLOCK_SIZE (128 * 1024) +#define RAB_POLY_MAX_BLOCK_SIZE_GLOBAL (64 * 1024) #define RAB_BLK_MASK (((1 << RAB_BLK_MIN_BITS) - 1) >> 1) #define RAB_BLK_AVG_SZ(x) (1 << ((x) + RAB_BLK_MIN_BITS)) diff --git a/utils/pcompress.sh b/utils/pcompress.sh new file mode 100644 index 0000000..b9c3816 --- /dev/null +++ b/utils/pcompress.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +PC_PATH="" +LD_LIBRARY_PATH="${PC_PATH}" +export LD_LIBRARY_PATH + +exec ${PC_PATH}/buildtmp/pcompress "$@" +