summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2007-02-18 02:41:57 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2007-02-18 02:41:57 +0000
commitcb24126c313a791a0705a2ecb740ab373cc5a612 (patch)
tree96b31c24f34652d646d2b9cf382cfe142bce6d16
parentf6cfb03ce353ba50c4d8d981014c038acc363e10 (diff)
raise default sprevsz, add command-line flag -P to set
-rw-r--r--xdelta3/Makefile9
-rw-r--r--xdelta3/setup.py14
-rw-r--r--xdelta3/xdelta3-main.h150
-rwxr-xr-xxdelta3/xdelta3-regtest.py73
-rw-r--r--xdelta3/xdelta3.c24
-rw-r--r--xdelta3/xdelta3.h6
-rw-r--r--xdelta3/xdelta3.prj43
7 files changed, 153 insertions, 166 deletions
diff --git a/xdelta3/Makefile b/xdelta3/Makefile
index 3bb7f44..03be11d 100644
--- a/xdelta3/Makefile
+++ b/xdelta3/Makefile
@@ -36,10 +36,10 @@ TARGETS = xdelta3-debug \
36PYTHON = python 36PYTHON = python
37 37
38SWIGTGT = xdelta3module.so 38SWIGTGT = xdelta3module.so
39SWIGTGT = xdelta3module.dll 39#SWIGTGT = xdelta3module.dll
40 40
41PYTGT = build/lib.linux-i686-2.4/xdelta3.so 41PYTGT = build/lib.linux-i686-2.4/xdelta3main.so
42PYTGT = build/lib.cygwin-1.5.24-i686-2.4/xdelta3main.dll 42#PYTGT = build/lib.cygwin-1.5.24-i686-2.4/xdelta3main.dll
43 43
44EXTRA = Makefile COPYING linkxd3lib.c badcopy.c xdelta3.swig \ 44EXTRA = Makefile COPYING linkxd3lib.c badcopy.c xdelta3.swig \
45 draft-korn-vcdiff.txt xdelta3.vcproj badcopy.vcproj \ 45 draft-korn-vcdiff.txt xdelta3.vcproj badcopy.vcproj \
@@ -47,6 +47,7 @@ EXTRA = Makefile COPYING linkxd3lib.c badcopy.c xdelta3.swig \
47 xdelta3.py xdelta3_wrap.c 47 xdelta3.py xdelta3_wrap.c
48 48
49SWIG_FLAGS = -DXD3_DEBUG=0 \ 49SWIG_FLAGS = -DXD3_DEBUG=0 \
50 -DEXTERNAL_COMPRESSION=0 \
50 -DXD3_USE_LARGEFILE64=1 \ 51 -DXD3_USE_LARGEFILE64=1 \
51 -DGENERIC_ENCODE_TABLES=1 \ 52 -DGENERIC_ENCODE_TABLES=1 \
52 -DSECONDARY_DJW=1 \ 53 -DSECONDARY_DJW=1 \
@@ -81,7 +82,7 @@ tar:
81 82
82clean: 83clean:
83 rm -f $(TARGETS) 84 rm -f $(TARGETS)
84 rm -rf build Debug Release core *.stackdump *.exe \ 85 rm -rf build Debug Release core cifs* *.stackdump *.exe \
85 xdelta3.ncb xdelta3.suo xdelta3.sln 86 xdelta3.ncb xdelta3.suo xdelta3.sln
86 87
87xdelta3: $(SOURCES) 88xdelta3: $(SOURCES)
diff --git a/xdelta3/setup.py b/xdelta3/setup.py
index f89aba7..abc902d 100644
--- a/xdelta3/setup.py
+++ b/xdelta3/setup.py
@@ -22,14 +22,8 @@ from distutils.util import get_platform
22# External compression support works on Windows/Cygwin, but not from 22# External compression support works on Windows/Cygwin, but not from
23# within the Python module. It's something to do with fork() and 23# within the Python module. It's something to do with fork() and
24# exec() support. 24# exec() support.
25platform = get_platform() 25#platform = get_platform()
26is_cygwin = platform.startswith('cygwin') 26#is_cygwin = platform.startswith('cygwin')
27extcomp = 1
28
29if is_cygwin:
30 print 'Note: not compiling external compression support for Python/Cygwin'
31 extcomp = 0
32#end
33 27
34xdelta3_ext = Extension('xdelta3main', 28xdelta3_ext = Extension('xdelta3main',
35 ['xdelta3.c'], 29 ['xdelta3.c'],
@@ -41,7 +35,9 @@ xdelta3_ext = Extension('xdelta3main',
41 ('XD3_POSIX',1), 35 ('XD3_POSIX',1),
42 ('XD3_USE_LARGEFILE64',1), 36 ('XD3_USE_LARGEFILE64',1),
43 37
44 ('EXTERNAL_COMPRESSION',extcomp), 38 # the fork/exec stuff doesn't
39 # work inside python.
40 ('EXTERNAL_COMPRESSION',0),
45 41
46 ('REGRESSION_TEST',0), 42 ('REGRESSION_TEST',0),
47 ('SECONDARY_FGK',0), 43 ('SECONDARY_FGK',0),
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index 2f1eb7f..3b7d11a 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -244,6 +244,10 @@ struct _main_blklru
244/* ... represented as a list (no cache index). */ 244/* ... represented as a list (no cache index). */
245XD3_MAKELIST(main_blklru_list,main_blklru,link); 245XD3_MAKELIST(main_blklru_list,main_blklru,link);
246 246
247// TODO:
248// struct _main_state
249// {
250
247/* Program options: various command line flags and options. */ 251/* Program options: various command line flags and options. */
248static int option_stdout = 0; 252static int option_stdout = 0;
249static int option_force = 0; 253static int option_force = 0;
@@ -264,10 +268,7 @@ static int option_level = XD3_DEFAULT_LEVEL;
264static usize_t option_iopt_size = XD3_DEFAULT_IOPT_SIZE; 268static usize_t option_iopt_size = XD3_DEFAULT_IOPT_SIZE;
265static usize_t option_winsize = XD3_DEFAULT_WINSIZE; 269static usize_t option_winsize = XD3_DEFAULT_WINSIZE;
266static usize_t option_srcwinsz = XD3_DEFAULT_SRCWINSZ; 270static usize_t option_srcwinsz = XD3_DEFAULT_SRCWINSZ;
267static int option_srcwinsz_set = 0; 271static usize_t option_sprevsz = XD3_DEFAULT_SPREVSZ;
268
269/* This controls the number of times main repeats itself, only for profiling. */
270static int option_profile_cnt = 0;
271 272
272/* These variables are supressed to avoid their use w/o support. main() warns 273/* These variables are supressed to avoid their use w/o support. main() warns
273 * appropriately. */ 274 * appropriately. */
@@ -317,6 +318,8 @@ static main_extcomp extcomp_types[] =
317 /*{ "lzma", "-cf", "lzma", "-dcf", "M", "]\000", 2, 0 },*/ 318 /*{ "lzma", "-cf", "lzma", "-dcf", "M", "]\000", 2, 0 },*/
318}; 319};
319 320
321// };
322
320static void main_get_appheader (xd3_stream *stream, main_file *ifile, 323static void main_get_appheader (xd3_stream *stream, main_file *ifile,
321 main_file *output, main_file *sfile); 324 main_file *output, main_file *sfile);
322 325
@@ -345,18 +348,18 @@ main_config (void)
345 P(RINT "VCDIFF_TOOLS=%d\n", VCDIFF_TOOLS); 348 P(RINT "VCDIFF_TOOLS=%d\n", VCDIFF_TOOLS);
346 P(RINT "XD3_ALLOCSIZE=%d\n", XD3_ALLOCSIZE); 349 P(RINT "XD3_ALLOCSIZE=%d\n", XD3_ALLOCSIZE);
347 P(RINT "XD3_DEBUG=%d\n", XD3_DEBUG); 350 P(RINT "XD3_DEBUG=%d\n", XD3_DEBUG);
351 P(RINT "XD3_ENCODER=%d\n", XD3_ENCODER);
352 P(RINT "XD3_POSIX=%d\n", XD3_POSIX);
353 P(RINT "XD3_STDIO=%d\n", XD3_STDIO);
354 P(RINT "XD3_WIN32=%d\n", XD3_WIN32);
355 P(RINT "XD3_USE_LARGEFILE64=%d\n", XD3_USE_LARGEFILE64);
348 P(RINT "XD3_DEFAULT_LEVEL=%d\n", XD3_DEFAULT_LEVEL); 356 P(RINT "XD3_DEFAULT_LEVEL=%d\n", XD3_DEFAULT_LEVEL);
349 P(RINT "XD3_DEFAULT_IOPT_SIZE=%d\n", XD3_DEFAULT_IOPT_SIZE); 357 P(RINT "XD3_DEFAULT_IOPT_SIZE=%d\n", XD3_DEFAULT_IOPT_SIZE);
350 P(RINT "XD3_DEFAULT_SPREVSZ=%d\n", XD3_DEFAULT_SPREVSZ); 358 P(RINT "XD3_DEFAULT_SPREVSZ=%d\n", XD3_DEFAULT_SPREVSZ);
351 P(RINT "XD3_DEFAULT_SRCWINSZ=%d\n", XD3_DEFAULT_SRCWINSZ); 359 P(RINT "XD3_DEFAULT_SRCWINSZ=%d\n", XD3_DEFAULT_SRCWINSZ);
352 P(RINT "XD3_DEFAULT_WINSIZE=%d\n", XD3_DEFAULT_WINSIZE); 360 P(RINT "XD3_DEFAULT_WINSIZE=%d\n", XD3_DEFAULT_WINSIZE);
353 P(RINT "XD3_ENCODER=%d\n", XD3_ENCODER);
354 P(RINT "XD3_HARDMAXWINSIZE=%d\n", XD3_HARDMAXWINSIZE); 361 P(RINT "XD3_HARDMAXWINSIZE=%d\n", XD3_HARDMAXWINSIZE);
355 P(RINT "XD3_NODECOMPRESSSIZE=%d\n", XD3_NODECOMPRESSSIZE); 362 P(RINT "XD3_NODECOMPRESSSIZE=%d\n", XD3_NODECOMPRESSSIZE);
356 P(RINT "XD3_USE_LARGEFILE64=%d\n", XD3_USE_LARGEFILE64);
357 P(RINT "XD3_POSIX=%d\n", XD3_POSIX);
358 P(RINT "XD3_STDIO=%d\n", XD3_STDIO);
359 P(RINT "XD3_WIN32=%d\n", XD3_WIN32);
360 363
361 return EXIT_SUCCESS; 364 return EXIT_SUCCESS;
362} 365}
@@ -364,29 +367,19 @@ main_config (void)
364static void 367static void
365reset_defaults(void) 368reset_defaults(void)
366{ 369{
370 // TODO: this is dumb, use an object
367 option_stdout = 0; 371 option_stdout = 0;
368 option_force = 0; 372 option_force = 0;
369 option_verbose = 0; 373 option_verbose = 0;
370 option_quiet = 0; 374 option_quiet = 0;
371 option_use_appheader = 1;
372 option_appheader = NULL; 375 option_appheader = NULL;
373 option_use_secondary = 0; 376 option_use_secondary = 0;
374 option_secondary = NULL; 377 option_secondary = NULL;
375 option_use_checksum = 1;
376 option_use_altcodetable = 0; 378 option_use_altcodetable = 0;
377 option_smatch_config = NULL; 379 option_smatch_config = NULL;
378 option_no_compress = 0; 380 option_no_compress = 0;
379 option_no_output = 0; 381 option_no_output = 0;
380 option_source_filename = NULL; 382 option_source_filename = NULL;
381 option_srcwinsz_set = 0;
382 option_profile_cnt = 0;
383#if EXTERNAL_COMPRESSION
384 option_decompress_inputs = 1;
385 option_recompress_outputs = 1;
386#endif
387#if VCDIFF_TOOLS
388 option_print_cpymode = 1;
389#endif
390 program_name = NULL; 383 program_name = NULL;
391 appheader_used = NULL; 384 appheader_used = NULL;
392 main_bdata = NULL; 385 main_bdata = NULL;
@@ -397,12 +390,22 @@ reset_defaults(void)
397 lru_misses = 0; 390 lru_misses = 0;
398 lru_filled = 0; 391 lru_filled = 0;
399 allow_fake_source = 0; 392 allow_fake_source = 0;
400 option_srcwinsz_set = 0;
401 option_smatch_config = NULL; 393 option_smatch_config = NULL;
394
395 option_use_appheader = 1;
396 option_use_checksum = 1;
397#if EXTERNAL_COMPRESSION
398 option_decompress_inputs = 1;
399 option_recompress_outputs = 1;
400#endif
401#if VCDIFF_TOOLS
402 option_print_cpymode = 1;
403#endif
402 option_level = XD3_DEFAULT_LEVEL; 404 option_level = XD3_DEFAULT_LEVEL;
403 option_srcwinsz = XD3_DEFAULT_SRCWINSZ; 405 option_iopt_size = XD3_DEFAULT_IOPT_SIZE;
404 option_winsize = XD3_DEFAULT_WINSIZE; 406 option_winsize = XD3_DEFAULT_WINSIZE;
405 option_srcwinsz = XD3_DEFAULT_SRCWINSZ; 407 option_srcwinsz = XD3_DEFAULT_SRCWINSZ;
408 option_sprevsz = XD3_DEFAULT_SPREVSZ;
406} 409}
407 410
408static void* 411static void*
@@ -2041,11 +2044,6 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour
2041 } 2044 }
2042 else 2045 else
2043 { 2046 {
2044 if (option_verbose)
2045 {
2046 XPR(NT "source file: %s\n", sfile->filename);
2047 }
2048
2049 if ((ret = main_file_open (sfile, sfile->filename, XO_READ)) || 2047 if ((ret = main_file_open (sfile, sfile->filename, XO_READ)) ||
2050 (ret = main_file_stat (sfile, & source->size, 1))) 2048 (ret = main_file_stat (sfile, & source->size, 1)))
2051 { 2049 {
@@ -2140,15 +2138,8 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour
2140 } 2138 }
2141 else 2139 else
2142 { 2140 {
2143 /* Minimum size check */
2144 option_srcwinsz = max(option_srcwinsz, XD3_MINSRCWINSZ); 2141 option_srcwinsz = max(option_srcwinsz, XD3_MINSRCWINSZ);
2145 2142
2146 if (!option_srcwinsz_set)
2147 {
2148 /* If the flag was not set, scale srcwinsz up to 64MB. */
2149 option_srcwinsz = min((xoff_t) XD3_DEFAULT_SRCWINSZ, source->size);
2150 }
2151
2152 source->blksize = (option_srcwinsz / LRU_SIZE); 2143 source->blksize = (option_srcwinsz / LRU_SIZE);
2153 lru_size = LRU_SIZE; 2144 lru_size = LRU_SIZE;
2154 } 2145 }
@@ -2156,6 +2147,19 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour
2156 main_blklru_list_init (& lru_list); 2147 main_blklru_list_init (& lru_list);
2157 main_blklru_list_init (& lru_free); 2148 main_blklru_list_init (& lru_free);
2158 2149
2150 if (option_verbose)
2151 {
2152 static char buf[32];
2153
2154 XPR(NT "source %s winsize %s size %"Q"u\n",
2155 sfile->filename, main_format_bcnt(option_srcwinsz, buf), source->size);
2156 }
2157
2158 if (option_verbose > 1)
2159 {
2160 XPR(NT "source block size: %u\n", source->blksize);
2161 }
2162
2159 if ((lru = main_malloc (sizeof (main_blklru) * lru_size)) == NULL) 2163 if ((lru = main_malloc (sizeof (main_blklru) * lru_size)) == NULL)
2160 { 2164 {
2161 ret = ENOMEM; 2165 ret = ENOMEM;
@@ -2175,13 +2179,6 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour
2175 main_blklru_list_push_back (& lru_free, & lru[i]); 2179 main_blklru_list_push_back (& lru_free, & lru[i]);
2176 } 2180 }
2177 2181
2178 if (option_verbose > 1)
2179 {
2180 XPR(NT "source window size: %u\n", option_srcwinsz);
2181 XPR(NT "source block size: %u\n", source->blksize);
2182 XPR(NT "source file: %s: %"Q"u bytes\n", sfile->realname, source->size);
2183 }
2184
2185 if (stream && (ret = xd3_set_source (stream, source))) 2182 if (stream && (ret = xd3_set_source (stream, source)))
2186 { 2183 {
2187 XPR(NT XD3_LIB_ERRMSG (stream, ret)); 2184 XPR(NT XD3_LIB_ERRMSG (stream, ret));
@@ -2197,6 +2194,23 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour
2197 return ret; 2194 return ret;
2198} 2195}
2199 2196
2197static void
2198main_set_winsize (main_file *ifile) {
2199 xoff_t file_size;
2200
2201 option_winsize = max(option_winsize, XD3_ALLOCSIZE);
2202
2203 if (main_file_stat (ifile, &file_size, 0) == 0)
2204 {
2205 option_winsize = (usize_t) min(file_size, (xoff_t) option_winsize);
2206 }
2207
2208 if (option_verbose > 1)
2209 {
2210 XPR(NT "input window size: %u\n", option_winsize);
2211 }
2212}
2213
2200/****************************************************************************************** 2214/******************************************************************************************
2201 Source routines 2215 Source routines
2202 ******************************************************************************************/ 2216 ******************************************************************************************/
@@ -2362,10 +2376,12 @@ main_input (xd3_cmd cmd,
2362 config.sec_addr.ngroups = 1; 2376 config.sec_addr.ngroups = 1;
2363 config.sec_inst.ngroups = 1; 2377 config.sec_inst.ngroups = 1;
2364 config.iopt_size = option_iopt_size; 2378 config.iopt_size = option_iopt_size;
2379 config.sprevsz = option_sprevsz;
2365 2380
2366 /* TODO: eliminate static variables. */
2367 do_not_lru = 0; 2381 do_not_lru = 0;
2368 2382
2383 start_time = get_millisecs_now ();
2384
2369 /* main_input setup. */ 2385 /* main_input setup. */
2370 switch ((int) cmd) 2386 switch ((int) cmd)
2371 { 2387 {
@@ -2477,12 +2493,7 @@ main_input (xd3_cmd cmd,
2477 return EXIT_FAILURE; 2493 return EXIT_FAILURE;
2478 } 2494 }
2479 2495
2480 start_time = get_millisecs_now (); 2496 main_set_winsize (ifile);
2481
2482 if (option_verbose > 1)
2483 {
2484 XPR(NT "input buffer size: %u\n", option_winsize);
2485 }
2486 2497
2487 if ((main_bdata = main_malloc (option_winsize)) == NULL) 2498 if ((main_bdata = main_malloc (option_winsize)) == NULL)
2488 { 2499 {
@@ -2499,8 +2510,6 @@ main_input (xd3_cmd cmd,
2499 } 2510 }
2500 } 2511 }
2501 2512
2502 option_winsize = max(option_winsize, XD3_ALLOCSIZE);
2503
2504 config.winsize = option_winsize; 2513 config.winsize = option_winsize;
2505 config.srcwin_maxsz = option_srcwinsz; 2514 config.srcwin_maxsz = option_srcwinsz;
2506 config.getblk = main_getblk_func; 2515 config.getblk = main_getblk_func;
@@ -2682,7 +2691,7 @@ main_input (xd3_cmd cmd,
2682 } 2691 }
2683 } 2692 }
2684 2693
2685 if (option_verbose > 0) 2694 if (option_verbose)
2686 { 2695 {
2687 char rrateavg[32], wrateavg[32], tm[32]; 2696 char rrateavg[32], wrateavg[32], tm[32];
2688 char rdb[32], wdb[32]; 2697 char rdb[32], wdb[32];
@@ -2789,9 +2798,10 @@ done:
2789 { 2798 {
2790 char tm[32]; 2799 char tm[32];
2791 long end_time = get_millisecs_now (); 2800 long end_time = get_millisecs_now ();
2792 XPR(NT "command finished in %s\n", main_format_millis (end_time - start_time, tm)); 2801 XPR(NT "finished in %s; input %"Q"u output %"Q"u bytes (%0.2f%%)\n",
2793 XPR(NT "input bytes: %"Q"u\n", ifile->nread); 2802 main_format_millis (end_time - start_time, tm),
2794 XPR(NT "output bytes: %"Q"u\n", ofile->nwrite); 2803 ifile->nread, ofile->nwrite,
2804 100.0 * ofile->nwrite / ifile->nread);
2795 } 2805 }
2796 2806
2797 return EXIT_SUCCESS; 2807 return EXIT_SUCCESS;
@@ -2900,7 +2910,7 @@ main (int argc, char **argv)
2900 main_file ifile; 2910 main_file ifile;
2901 main_file ofile; 2911 main_file ofile;
2902 main_file sfile; 2912 main_file sfile;
2903 static char *flags = "0123456789cdefhnqvDJNORTVs:B:C:E:F:I:L:O:P:M:W:A::S::"; 2913 static const char *flags = "0123456789cdefhnqvDJNORTVs:B:C:E:F:I:L:O:M:P:W:A::S::";
2904 int my_optind; 2914 int my_optind;
2905 char *my_optarg; 2915 char *my_optarg;
2906 char *my_optstr; 2916 char *my_optstr;
@@ -2921,7 +2931,6 @@ main (int argc, char **argv)
2921 2931
2922 reset_defaults(); 2932 reset_defaults();
2923 2933
2924 go: /* Go. */
2925 free_argv = NULL; 2934 free_argv = NULL;
2926 free_value = NULL; 2935 free_value = NULL;
2927 setup_environment(argc, argv, &env_argc, &env_argv, &free_argv, &free_value); 2936 setup_environment(argc, argv, &env_argc, &env_argv, &free_argv, &free_value);
@@ -3077,22 +3086,6 @@ main (int argc, char **argv)
3077 XPR(NT "encoder support not compiled\n"); 3086 XPR(NT "encoder support not compiled\n");
3078 return EXIT_FAILURE; 3087 return EXIT_FAILURE;
3079#endif 3088#endif
3080 case 'P':
3081 /* only set profile count once, since... */
3082 if (option_profile_cnt == 0)
3083 {
3084 if ((ret = main_atou(my_optarg, (usize_t*) & option_profile_cnt, 0, 0, 'P')))
3085 {
3086 goto exit;
3087 }
3088
3089 if (option_profile_cnt <= 0)
3090 {
3091 ret = EXIT_SUCCESS;
3092 goto exit;
3093 }
3094 }
3095 break;
3096 3089
3097 case 'n': option_use_checksum = 0; break; 3090 case 'n': option_use_checksum = 0; break;
3098 case 'N': option_no_compress = 1; break; 3091 case 'N': option_no_compress = 1; break;
@@ -3104,7 +3097,6 @@ main (int argc, char **argv)
3104 case 'A': if (my_optarg == NULL) { option_use_appheader = 0; } 3097 case 'A': if (my_optarg == NULL) { option_use_appheader = 0; }
3105 else { option_appheader = (uint8_t*) my_optarg; } break; 3098 else { option_appheader = (uint8_t*) my_optarg; } break;
3106 case 'B': 3099 case 'B':
3107 option_srcwinsz_set = 1;
3108 if ((ret = main_atou (my_optarg, & option_srcwinsz, XD3_MINSRCWINSZ, 3100 if ((ret = main_atou (my_optarg, & option_srcwinsz, XD3_MINSRCWINSZ,
3109 0, 'B'))) 3101 0, 'B')))
3110 { 3102 {
@@ -3118,6 +3110,13 @@ main (int argc, char **argv)
3118 goto exit; 3110 goto exit;
3119 } 3111 }
3120 break; 3112 break;
3113 case 'P':
3114 if ((ret = main_atou (my_optarg, & option_sprevsz, 0,
3115 0, 'P')))
3116 {
3117 goto exit;
3118 }
3119 break;
3121 case 'W': 3120 case 'W':
3122 if ((ret = main_atou (my_optarg, & option_winsize, XD3_ALLOCSIZE, 3121 if ((ret = main_atou (my_optarg, & option_winsize, XD3_ALLOCSIZE,
3123 XD3_HARDMAXWINSIZE, 'W'))) 3122 XD3_HARDMAXWINSIZE, 'W')))
@@ -3264,8 +3263,6 @@ main (int argc, char **argv)
3264 3263
3265 main_cleanup (); 3264 main_cleanup ();
3266 3265
3267 if (--option_profile_cnt > 0 && ret == EXIT_SUCCESS) { goto go; }
3268
3269 fflush (stdout); 3266 fflush (stdout);
3270 fflush (stderr); 3267 fflush (stderr);
3271 return ret; 3268 return ret;
@@ -3304,6 +3301,7 @@ main_help (void)
3304 P(RINT "memory options:\n"); 3301 P(RINT "memory options:\n");
3305 P(RINT " -B bytes source window size\n"); 3302 P(RINT " -B bytes source window size\n");
3306 P(RINT " -W bytes input window size\n"); 3303 P(RINT " -W bytes input window size\n");
3304 P(RINT " -P size compression duplicates window\n");
3307 P(RINT " -I size instruction buffer size (0 = unlimited)\n"); 3305 P(RINT " -I size instruction buffer size (0 = unlimited)\n");
3308 3306
3309 P(RINT "compression options:\n"); 3307 P(RINT "compression options:\n");
@@ -3322,9 +3320,11 @@ main_help (void)
3322 P(RINT " -P repeat count (for profiling)\n"); 3320 P(RINT " -P repeat count (for profiling)\n");
3323 P(RINT " -T use alternate code table\n"); 3321 P(RINT " -T use alternate code table\n");
3324#endif 3322#endif
3323
3325 P(RINT "the XDELTA environment variable may contain extra args:\n"); 3324 P(RINT "the XDELTA environment variable may contain extra args:\n");
3326 P(RINT " XDELTA=\"-s source-x.y.tar.gz\" \\\n"); 3325 P(RINT " XDELTA=\"-s source-x.y.tar.gz\" \\\n");
3327 P(RINT " tar --use-compress-program=xdelta3 \\\n"); 3326 P(RINT " tar --use-compress-program=xdelta3 \\\n");
3328 P(RINT " -cf target-x.z.tar.gz.vcdiff target-x.y/\n"); 3327 P(RINT " -cf target-x.z.tar.gz.vcdiff target-x.y/\n");
3329 return EXIT_FAILURE; 3328 return EXIT_FAILURE;
3330} 3329}
3330
diff --git a/xdelta3/xdelta3-regtest.py b/xdelta3/xdelta3-regtest.py
index 30bccb1..1248584 100755
--- a/xdelta3/xdelta3-regtest.py
+++ b/xdelta3/xdelta3-regtest.py
@@ -23,7 +23,6 @@ import os, sys, math, re, time, types, array, random
23import xdelta3main 23import xdelta3main
24import xdelta3 24import xdelta3
25 25
26HIST_SIZE = 10 # the number of buckets
27MIN_SIZE = 0 26MIN_SIZE = 0
28 27
29TIME_TOO_SHORT = 0.050 28TIME_TOO_SHORT = 0.050
@@ -32,19 +31,26 @@ SKIP_TRIALS = 2
32MIN_TRIALS = 3 31MIN_TRIALS = 3
33MAX_TRIALS = 15 32MAX_TRIALS = 15
34 33
35MIN_STDDEV_PCT = 1.5 34# 10 = fast 1.5 = slow
36 35MIN_STDDEV_PCT = 10
37MIN_RUN = 1000 * 1000 * 1
38MAX_RUN = 1000 * 1000 * 10
39 36
40# How many results per round 37# How many results per round
41MAX_RESULTS = 6 38MAX_RESULTS = 4
42KEEP_P = (1.0) 39KEEP_P = (1.0)
43FAST_P = (0.0) 40FAST_P = (0.0)
44SLOW_P = (0.0) 41SLOW_P = (0.0)
42
43# For RCS testing, what percent to select
45FILE_P = (0.30) 44FILE_P = (0.30)
46 45
47# the first 10 args go to -C 46# For run-speed tests
47MIN_RUN = 1000 * 1000 * 1
48MAX_RUN = 1000 * 1000 * 10
49
50# Testwide defaults
51ALL_ARGS = [ '-f' ]
52
53# The first 10 args go to -C
48SOFT_CONFIG_CNT = 10 54SOFT_CONFIG_CNT = 10
49 55
50CONFIG_ORDER = [ 'large_look', 56CONFIG_ORDER = [ 'large_look',
@@ -59,15 +65,22 @@ CONFIG_ORDER = [ 'large_look',
59 'promote', 65 'promote',
60 'winsize', 66 'winsize',
61 'srcwinsize', 67 'srcwinsize',
68 'sprevsz',
69 'iopt',
70
71 # TODO: nocompress, djw (boolean flags)
62 ] 72 ]
63 73
64CONFIG_ARGMAP = { 74CONFIG_ARGMAP = {
65 'winsize' : '-W', 75 'winsize' : '-W',
66 'srcwinsize' : '-B', 76 'srcwinsize' : '-B',
77 'sprevsz' : '-P',
78 'iopt' : '-I',
67 } 79 }
68 80
69def INPUT_SPEC(rand): 81def INPUT_SPEC(rand):
70 return { 82 return {
83 # computational costs
71 'large_look' : lambda d: rand.choice([9]), 84 'large_look' : lambda d: rand.choice([9]),
72 'large_step' : lambda d: rand.choice([15]), 85 'large_step' : lambda d: rand.choice([15]),
73 86
@@ -78,25 +91,29 @@ def INPUT_SPEC(rand):
78 'long_enough' : lambda d: rand.choice([18]), 91 'long_enough' : lambda d: rand.choice([18]),
79 92
80 'small_look' : lambda d: rand.choice([4]), 93 'small_look' : lambda d: rand.choice([4]),
81 'promote' : lambda d: 0, 94 'ssmatch' : lambda d: rand.choice([0]),
82 'trylazy' : lambda d: 1,
83 'ssmatch' : lambda d: 0,
84 95
85 'winsize' : lambda d: rand.choice( 96 'promote' : lambda d: rand.choice([0]),
86 [x * (1<<20) for x in [1, 4, 8, 16, 32, 64]]),
87 97
88 'srcwinsize' : lambda d: 1<<26, 98 'trylazy' : lambda d: rand.choice([1]),
89 } 99
100 # memory costs
101 'iopt' : lambda d: 0, # unlimited
90 102
103 'winsize' : lambda d: 8 * (1<<20),
104 'srcwinsize' : lambda d: 64 * (1<<20),
105
106 'sprevsz' : lambda d: 1 * (1<<18), # only powers of two
107 }
91 108
92# 109#
93# 110#
94#RCSDIR = '/mnt/polaroid/Polaroid/orbit_linux/home/jmacd/PRCS' 111#RCSDIR = '/mnt/polaroid/Polaroid/orbit_linux/home/jmacd/PRCS'
95#RCSDIR = '/tmp/PRCS_read_copy' 112RCSDIR = '/tmp/PRCS_read_copy/prcs'
113SAMPLEDIR = "/tmp/WESNOTH_tmp/tar"
96 114
97RCSDIR = 'G:/jmacd/PRCS/prcs/b' 115#RCSDIR = 'G:/jmacd/PRCS/prcs/b'
98 116#SAMPLEDIR = "C:/sample_data/Wesnoth/tar"
99SAMPLEDIR = "C:/sample_data/Wesnoth/tar"
100 117
101TMPDIR = '/tmp/xd3regtest.%d' % os.getpid() 118TMPDIR = '/tmp/xd3regtest.%d' % os.getpid()
102 119
@@ -121,19 +138,6 @@ RE_DATE = re.compile('date: ([^;]+);.*')
121RE_HDRSZ = re.compile('VCDIFF header size: +(\\d+)') 138RE_HDRSZ = re.compile('VCDIFF header size: +(\\d+)')
122RE_EXTCOMP = re.compile('XDELTA ext comp.*') 139RE_EXTCOMP = re.compile('XDELTA ext comp.*')
123 140
124# Testwide defaults
125testwide_encode_args = [
126
127 # secondary compression on or off
128 #'-S', 'djw',
129
130 # do not measure instruction buffer effects
131 '-I', '0',
132
133 # do not attempt external decompression
134 '-D'
135 ]
136
137def c2s(c): 141def c2s(c):
138 return ' '.join(['%02d' % x for x in c]) 142 return ' '.join(['%02d' % x for x in c])
139#end 143#end
@@ -342,9 +346,9 @@ class Xdelta3Runner:
342 #end 346 #end
343 347
344 def Encode(self, target, source, output): 348 def Encode(self, target, source, output):
345 args = (testwide_encode_args + 349 args = (ALL_ARGS +
346 self.extra + 350 self.extra +
347 ['-eqf']) 351 ['-e'])
348 if source: 352 if source:
349 args.append('-s') 353 args.append('-s')
350 args.append(source) 354 args.append(source)
@@ -354,7 +358,8 @@ class Xdelta3Runner:
354 #end 358 #end
355 359
356 def Decode(self, input, source, output): 360 def Decode(self, input, source, output):
357 args = ['-dqf'] 361 args = (ALL_ARGS +
362 ['-d'])
358 if source: 363 if source:
359 args.append('-s') 364 args.append('-s')
360 args.append(source) 365 args.append(source)
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c
index 7042903..b6ac778 100644
--- a/xdelta3/xdelta3.c
+++ b/xdelta3/xdelta3.c
@@ -101,18 +101,7 @@
101 the parameters of the source window must be decided: the offset into 101 the parameters of the source window must be decided: the offset into
102 the source and the length of the window. Since the IOPT buffer is 102 the source and the length of the window. Since the IOPT buffer is
103 finite, the program may be forced to fix these values before knowing 103 finite, the program may be forced to fix these values before knowing
104 the best offset/length. XD3_DEFAULT_SRCBACK limits the length, but a 104 the best offset/length.
105 smaller length is preferred because all target copies are addressed
106 after source copies in the VCDIFF address space. Picking too large a
107 source window means larger address encoding.
108
109 If the IOPT buffer is filling easily, perhaps the target window is
110 too large. In any case, a decision is made (though an alternative is
111 to emit the sub-window right away, to reduce the winsize
112 automatically - not implemented, another alternative is to grow the
113 IOPT buffer, it is after all bounded in size by winsize.)
114
115 The algorithm is in xd3_srcwin_setup.
116 105
117 5. SECONDARY COMPRESSION. VCDIFF supports a secondary encoding to 106 5. SECONDARY COMPRESSION. VCDIFF supports a secondary encoding to
118 be applied to the individual sections of the data format, which are 107 be applied to the individual sections of the data format, which are
@@ -126,9 +115,9 @@
126 case of a semi-adaptive scheme published by D.J. Wheeler and first 115 case of a semi-adaptive scheme published by D.J. Wheeler and first
127 widely used in bzip2 (by Julian Seward). This is a very 116 widely used in bzip2 (by Julian Seward). This is a very
128 interesting algorithm, originally published in nearly cryptic form 117 interesting algorithm, originally published in nearly cryptic form
129 by D.J. Wheeler. !!!NOTE!!! Because these are not standardized, the 118 by D.J. Wheeler. !!!NOTE!!! Because these are not standardized,
130 -S option (no secondary compression) remains on by default. 119 secondary compression remains off by default.
131 ftp://ftp.cl.cam.ac.uk/users/djw3/bred3.{c,ps} 120 ftp://ftp.cl.cam.ac.uk/users/djw3/bred3.{c,ps}
132 -------------------------------------------------------------------- 121 --------------------------------------------------------------------
133 122
134 Other Features 123 Other Features
@@ -3543,8 +3532,6 @@ xd3_encode_init (xd3_stream *stream)
3543 /* Memory allocations for checksum tables are delayed until xd3_string_match_init in the 3532 /* Memory allocations for checksum tables are delayed until xd3_string_match_init in the
3544 * first call to string_match--that way identical or short inputs require no table 3533 * first call to string_match--that way identical or short inputs require no table
3545 * allocation. */ 3534 * allocation. */
3546
3547 /* TODO: need to experiment w/ XD3_DEFAULT_SPREVSZ and large has functions */
3548 if (large_comp) 3535 if (large_comp)
3549 { 3536 {
3550 usize_t hash_values = (stream->srcwin_maxsz / stream->smatcher.large_step); 3537 usize_t hash_values = (stream->srcwin_maxsz / stream->smatcher.large_step);
@@ -3556,8 +3543,7 @@ xd3_encode_init (xd3_stream *stream)
3556 3543
3557 if (small_comp) 3544 if (small_comp)
3558 { 3545 {
3559 /* Hard-coded, keeps table small because small matches become inefficient. */ 3546 usize_t hash_values = min(stream->winsize, stream->sprevsz);
3560 usize_t hash_values = min(stream->winsize, XD3_DEFAULT_SPREVSZ);
3561 3547
3562 xd3_size_hashtable (stream, 3548 xd3_size_hashtable (stream,
3563 hash_values, 3549 hash_values,
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h
index b4c0a4e..6204d3f 100644
--- a/xdelta3/xdelta3.h
+++ b/xdelta3/xdelta3.h
@@ -35,7 +35,7 @@
35 * automatically buffer the input, otherwise the input buffer is used directly. 35 * automatically buffer the input, otherwise the input buffer is used directly.
36 */ 36 */
37#ifndef XD3_DEFAULT_WINSIZE 37#ifndef XD3_DEFAULT_WINSIZE
38#define XD3_DEFAULT_WINSIZE (1U << 18) 38#define XD3_DEFAULT_WINSIZE (1U << 23)
39#endif 39#endif
40 40
41/* Default total size of the source window used in xdelta3-main.h */ 41/* Default total size of the source window used in xdelta3-main.h */
@@ -53,7 +53,7 @@
53 * malicious files. The decoder will never decode a window larger than this. If the file 53 * malicious files. The decoder will never decode a window larger than this. If the file
54 * specifies VCD_TARGET the decoder may require two buffers of this size. 54 * specifies VCD_TARGET the decoder may require two buffers of this size.
55 * 55 *
56 * 8-16MB is reasonable, probably don't need to go larger. 56 * 8-16MB is reasonable, probably don't need to go larger. */
57#ifndef XD3_HARDMAXWINSIZE 57#ifndef XD3_HARDMAXWINSIZE
58#define XD3_HARDMAXWINSIZE (1U<<24) 58#define XD3_HARDMAXWINSIZE (1U<<24)
59#endif 59#endif
@@ -76,7 +76,7 @@
76 76
77/* The maximum distance backward to search for small matches */ 77/* The maximum distance backward to search for small matches */
78#ifndef XD3_DEFAULT_SPREVSZ 78#ifndef XD3_DEFAULT_SPREVSZ
79#define XD3_DEFAULT_SPREVSZ (1U << 16) 79#define XD3_DEFAULT_SPREVSZ (1U<<18)
80#endif 80#endif
81 81
82/* The default compression level 82/* The default compression level
diff --git a/xdelta3/xdelta3.prj b/xdelta3/xdelta3.prj
index 52ad972..10c9f77 100644
--- a/xdelta3/xdelta3.prj
+++ b/xdelta3/xdelta3.prj
@@ -1,52 +1,51 @@
1;; -*- Prcs -*- 1;; -*- Prcs -*-
2(Created-By-Prcs-Version 1 3 4) 2(Created-By-Prcs-Version 1 3 4)
3(Project-Description "") 3(Project-Description "")
4(Project-Version xdelta3 0 18) 4(Project-Version xdelta3 0 19)
5(Parent-Version xdelta3 0 17) 5(Parent-Version xdelta3 0 18)
6(Version-Log "release 3.0o final") 6(Version-Log "pre-3.0p")
7(New-Version-Log "") 7(New-Version-Log "")
8(Checkin-Time "Wed, 07 Feb 2007 18:59:06 -0800") 8(Checkin-Time "Sat, 17 Feb 2007 04:08:43 -0800")
9(Checkin-Login jmacd) 9(Checkin-Login jmacd)
10(Populate-Ignore ()) 10(Populate-Ignore ("\\.svn"))
11(Project-Keywords 11(Project-Keywords
12 (Xdelta3Version "0o") 12 (Xdelta3Version "0o")
13 ) 13 )
14(Files 14(Files
15 (COPYING (xdelta3/b/29_COPYING 1.1 644)) 15 (COPYING (xdelta3/b/29_COPYING 1.1 744))
16 16
17 (xdelta3-cfgs.h (xdelta3/9_xdelta3-cf 1.5 744)) 17 (xdelta3-cfgs.h (xdelta3/9_xdelta3-cf 1.5 744))
18 (xdelta3-decode.h (xdelta3/b/30_xdelta3-de 1.5 744)) 18 (xdelta3-decode.h (xdelta3/b/30_xdelta3-de 1.5 744))
19 (xdelta3-djw.h (xdelta3/8_xdelta3-dj 1.5 744)) 19 (xdelta3-djw.h (xdelta3/8_xdelta3-dj 1.6 744))
20 (xdelta3-fgk.h (xdelta3/7_xdelta3-fg 1.3 744)) 20 (xdelta3-fgk.h (xdelta3/7_xdelta3-fg 1.3 744))
21 (xdelta3-list.h (xdelta3/6_xdelta3-li 1.3 644)) 21 (xdelta3-list.h (xdelta3/6_xdelta3-li 1.3 744))
22 (xdelta3-main.h (xdelta3/5_xdelta3-ma 1.11 744)) 22 (xdelta3-main.h (xdelta3/5_xdelta3-ma 1.12 744))
23 (xdelta3-python.h (xdelta3/4_xdelta3-py 1.4 744)) 23 (xdelta3-python.h (xdelta3/4_xdelta3-py 1.5 744))
24 (xdelta3-regtest.py (xdelta3/10_xdelta3-re 1.10 744)) 24 (xdelta3-regtest.py (xdelta3/10_xdelta3-re 1.11 744))
25 (xdelta3-second.h (xdelta3/3_xdelta3-se 1.4 744)) 25 (xdelta3-second.h (xdelta3/3_xdelta3-se 1.4 744))
26 (xdelta3-test.h (xdelta3/2_xdelta3-te 1.10 744)) 26 (xdelta3-test.h (xdelta3/2_xdelta3-te 1.10 744))
27 (xdelta3.c (xdelta3/16_xdelta3.c 1.10 744)) 27 (xdelta3.c (xdelta3/16_xdelta3.c 1.11 744))
28 (xdelta3.h (xdelta3/1_xdelta3.h 1.8 744)) 28 (xdelta3.h (xdelta3/1_xdelta3.h 1.9 744))
29 29
30 (Makefile (xdelta3/0_Makefile 1.9 744)) 30 (Makefile (xdelta3/0_Makefile 1.10 744))
31 (setup.py (xdelta3/11_setup.py 1.4 744)) 31 (setup.py (xdelta3/11_setup.py 1.5 744))
32 32
33 (draft-korn-vcdiff.txt (xdelta3/b/22_draft-korn 1.1 644)) 33 (draft-korn-vcdiff.txt (xdelta3/b/22_draft-korn 1.1 744))
34 34
35 (badcopy.c (xdelta3/20_badcopy.c 1.2 744)) 35 (badcopy.c (xdelta3/20_badcopy.c 1.2 744))
36 (linkxd3lib.c (xdelta3/19_linkxd3lib 1.3 744)) 36 (linkxd3lib.c (xdelta3/19_linkxd3lib 1.3 744))
37 (rcs_junk.cc (xdelta3/15_rcs_junk.c 1.1 644)) 37 (rcs_junk.cc (xdelta3/15_rcs_junk.c 1.1 744))
38 38
39 (README (xdelta3/b/31_README 1.1 744)) 39 (README (xdelta3/b/31_README 1.1 744))
40 (badcopy.vcproj (xdelta3/b/32_badcopy.vc 1.1 744)) 40 (badcopy.vcproj (xdelta3/b/32_badcopy.vc 1.1 744))
41 (xdelta3.vcproj (xdelta3/b/33_xdelta3.vc 1.2 744)) 41 (xdelta3.vcproj (xdelta3/b/33_xdelta3.vc 1.2 744))
42 42
43 (xdelta3.swig (xdelta3/b/27_xdelta3.sw 1.2 744)) 43 (xdelta3.swig (xdelta3/b/27_xdelta3.sw 1.3 744))
44 44
45 (xdelta3-test.py (xdelta3/b/28_xdelta3-te 1.3 744))
45 46
46;; Files added by populate at Wed, 07 Feb 2007 13:33:45 -0800, 47 (examples/Makefile (xdelta3/b/34_Makefile 1.1 744))
47;; to version 0.14(w), by jmacd: 48 (examples/small_page_test.c (xdelta3/b/35_small_page 1.1 744))
48
49 (xdelta3-test.py (xdelta3/b/28_xdelta3-te 1.2 744))
50) 49)
51(Merge-Parents) 50(Merge-Parents)
52(New-Merge-Parents) 51(New-Merge-Parents)