summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2015-07-28 12:39:36 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2015-07-28 13:02:27 +0200
commitb7063ed1ae11be90824d1af4934204cf09f0f53a (patch)
treecae3bf85792df9e583b2699da5a095300cabb656 /src
parentcac92f62c478288c50b401562d3d3c9baec8e71d (diff)
downloadostree-b7063ed1ae11be90824d1af4934204cf09f0f53a.tar.gz
static-delta: add max-bsdiff-size option
It allows to specify the maximum size for input files to attempt bsdiff compression for. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/libostree/ostree-repo-static-delta-compilation.c16
-rw-r--r--src/ostree/ot-builtin-static-delta.c5
2 files changed, 17 insertions, 4 deletions
diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c
index 6f1513c9..aafe6fba 100644
--- a/src/libostree/ostree-repo-static-delta-compilation.c
+++ b/src/libostree/ostree-repo-static-delta-compilation.c
@@ -53,6 +53,7 @@ typedef struct {
GPtrArray *fallback_objects;
guint64 loose_compressed_size;
guint64 min_fallback_size_bytes;
+ guint64 max_bsdiff_size_bytes;
guint64 max_chunk_size_bytes;
guint64 rollsum_size;
guint n_rollsum;
@@ -500,8 +501,9 @@ try_content_bsdiff (OstreeRepo *repo,
const char *from,
const char *to,
ContentBsdiff **out_bsdiff,
+ guint64 max_bsdiff_size_bytes,
GCancellable *cancellable,
- GError **error)
+ GError **error)
{
gboolean ret = FALSE;
g_autoptr(GHashTable) from_bsdiff = NULL;
@@ -521,8 +523,7 @@ try_content_bsdiff (OstreeRepo *repo,
cancellable, error))
goto out;
- /* TODO: make this option configurable. */
- if (g_bytes_get_size (tmp_to) + g_bytes_get_size (tmp_from) > (200 * (1 << 20)))
+ if (g_bytes_get_size (tmp_to) + g_bytes_get_size (tmp_from) > max_bsdiff_size_bytes)
{
ret = TRUE;
goto out;
@@ -1008,7 +1009,8 @@ generate_delta_lowlatency (OstreeRepo *repo,
if (!(opts & DELTAOPT_FLAG_DISABLE_BSDIFF))
{
if (!try_content_bsdiff (repo, from_checksum, to_checksum,
- &bsdiff, cancellable, error))
+ &bsdiff, builder->max_bsdiff_size_bytes,
+ cancellable, error))
goto out;
if (bsdiff)
@@ -1228,6 +1230,8 @@ get_fallback_headers (OstreeRepo *self,
* are known:
* - min-fallback-size: u: Minimume uncompressed size in megabytes to use fallback
* - max-chunk-size: u: Maximum size in megabytes of a delta part
+ * - max-bsdiff-size: u: Maximum size in megabytes to consider bsdiff compression
+ * for input files
* - compression: y: Compression type: 0=none, x=lzma, g=gzip
* - bsdiff-enabled: b: Enable bsdiff compression. Default TRUE.
* - verbose: b: Print diagnostic messages. Default FALSE.
@@ -1246,6 +1250,7 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
OstreeStaticDeltaBuilder builder = { 0, };
guint i;
guint min_fallback_size;
+ guint max_bsdiff_size;
guint max_chunk_size;
GVariant *metadata_source;
DeltaOpts delta_opts = DELTAOPT_FLAG_NONE;
@@ -1268,6 +1273,9 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
min_fallback_size = 4;
builder.min_fallback_size_bytes = ((guint64)min_fallback_size) * 1000 * 1000;
+ if (!g_variant_lookup (params, "max-bsdiff-size", "u", &max_bsdiff_size))
+ max_bsdiff_size = 128;
+ builder.max_bsdiff_size_bytes = ((guint64)max_bsdiff_size) * 1000 * 1000;
if (!g_variant_lookup (params, "max-chunk-size", "u", &max_chunk_size))
max_chunk_size = 32;
builder.max_chunk_size_bytes = ((guint64)max_chunk_size) * 1000 * 1000;
diff --git a/src/ostree/ot-builtin-static-delta.c b/src/ostree/ot-builtin-static-delta.c
index 04aab0b5..abb0b635 100644
--- a/src/ostree/ot-builtin-static-delta.c
+++ b/src/ostree/ot-builtin-static-delta.c
@@ -29,6 +29,7 @@
static char *opt_from_rev;
static char *opt_to_rev;
static char *opt_min_fallback_size;
+static char *opt_max_bsdiff_size;
static char *opt_max_chunk_size;
static gboolean opt_empty;
static gboolean opt_disable_bsdiff;
@@ -55,6 +56,7 @@ static GOptionEntry generate_options[] = {
{ "to", 0, 0, G_OPTION_ARG_STRING, &opt_to_rev, "Create delta to revision REV", "REV" },
{ "disable-bsdiff", 0, 0, G_OPTION_ARG_NONE, &opt_disable_bsdiff, "Disable use of bsdiff", NULL },
{ "min-fallback-size", 0, 0, G_OPTION_ARG_STRING, &opt_min_fallback_size, "Minimum uncompressed size in megabytes for individual HTTP request", NULL},
+ { "max-bsdiff-size", 0, 0, G_OPTION_ARG_STRING, &opt_max_bsdiff_size, "Maximum size in megabytes to consider bsdiff compression for input files", NULL},
{ "max-chunk-size", 0, 0, G_OPTION_ARG_STRING, &opt_max_chunk_size, "Maximum size of delta chunks in megabytes", NULL},
{ NULL }
};
@@ -190,6 +192,9 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab
if (opt_min_fallback_size)
g_variant_builder_add (parambuilder, "{sv}",
"min-fallback-size", g_variant_new_uint32 (g_ascii_strtoull (opt_min_fallback_size, NULL, 10)));
+ if (opt_max_bsdiff_size)
+ g_variant_builder_add (parambuilder, "{sv}",
+ "max-bsdiff-size", g_variant_new_uint32 (g_ascii_strtoull (opt_max_bsdiff_size, NULL, 10)));
if (opt_max_chunk_size)
g_variant_builder_add (parambuilder, "{sv}",
"max-chunk-size", g_variant_new_uint32 (g_ascii_strtoull (opt_max_chunk_size, NULL, 10)));