Rework the frontend and backend to allow passing a ratio value in for
UseDelta rather than having a hardcoded #define-d 0.7 value always used.
This is useful for those with fast connections, who would likely benefit
from tuning this ratio to lower values; it is also useful for general
testing purposes.
The libalpm API changes for this, but we do support the old config file
format with a no-value 'UseDelta' option; in this case we simply use the
old default of 0.7.
We clamp the ratio values to a sane range between 0.0 and 2.0, allowing
ratios above 1.0 for testing purposes.
diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt
index 2c1a24b..3913292 100644
--- a/doc/pacman.conf.5.txt
+++ b/doc/pacman.conf.5.txt
@@ -168,9 +168,13 @@ Options
Log action messages through syslog(). This will insert log entries into
+{localstatedir}/log/messages+ or equivalent.
-*UseDelta*::
- Download delta files instead of complete packages if possible. Requires
- the xdelta3 program to be installed.
+*UseDelta* [= ratio]::
+ Download delta files instead of complete packages if possible. Requires
+ the `xdelta3` program to be installed. If a ratio is specified (e.g.,
+ `0.5`), then it is used as a cutoff for determining whether to use deltas.
+ Allowed values are between `0.0` and `2.0`; sensible values are between
+ `0.2` and `0.9`. Using a value above `1.0` is not recommended. The
+ default is `0.7` if left unspecified.
/* options */
char *arch; /* Architecture of packages we should allow */
+ double deltaratio; /* Download deltas if possible; a ratio value */
int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
- int usedelta; /* Download deltas if possible */
int checkspace; /* Check disk space before installing */
alpm_siglevel_t siglevel; /* Default signature verification level */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 49a3f42..6967b49 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -318,13 +318,13 @@ static int compute_download_size(alpm_pkg_t *newpkg)
/* tell the caller that we have a partial */
ret = 1;
- } else if(handle->usedelta) {
+ } else if(handle->deltaratio > 0.0) {
off_t dltsize;
alpm_option_set_ignorepkgs(handle, config->ignorepkg);
alpm_option_set_ignoregroups(handle, config->ignoregrp);
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 325fbb6..481132f 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -34,7 +34,7 @@ typedef struct __config_t {
unsigned short print;
unsigned short checkspace;
unsigned short usesyslog;
- unsigned short usedelta;
+ double deltaratio;
char *arch;
char *print_format;
/* unfortunately, we have to keep track of paths both here and in the library
--
1.7.8.3
01-11-2012, 11:52 PM
Allan McRae
Allow UseDelta option to specify a delta ratio
On 12/01/12 07:42, Dan McGee wrote:
> Rework the frontend and backend to allow passing a ratio value in for
> UseDelta rather than having a hardcoded #define-d 0.7 value always used.
> This is useful for those with fast connections, who would likely benefit
> from tuning this ratio to lower values; it is also useful for general
> testing purposes.
>
> The libalpm API changes for this, but we do support the old config file
> format with a no-value 'UseDelta' option; in this case we simply use the
> old default of 0.7.
>
> We clamp the ratio values to a sane range between 0.0 and 2.0, allowing
> ratios above 1.0 for testing purposes.
>
> Signed-off-by: Dan McGee <dan@archlinux.org>
Ack-by: Allan
Looks good from some basic testing here.
My only thought (which is possibly full of bikeshed, so feel free to
ignore...) was do we really want to stick with a ratio or move to an
absolute size difference? 0.9 of a 100MB package is much more useful
than 0.9 of a 1KB package.