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>
This commit is contained in:
parent
cac92f62c4
commit
b7063ed1ae
|
|
@ -53,6 +53,7 @@ typedef struct {
|
||||||
GPtrArray *fallback_objects;
|
GPtrArray *fallback_objects;
|
||||||
guint64 loose_compressed_size;
|
guint64 loose_compressed_size;
|
||||||
guint64 min_fallback_size_bytes;
|
guint64 min_fallback_size_bytes;
|
||||||
|
guint64 max_bsdiff_size_bytes;
|
||||||
guint64 max_chunk_size_bytes;
|
guint64 max_chunk_size_bytes;
|
||||||
guint64 rollsum_size;
|
guint64 rollsum_size;
|
||||||
guint n_rollsum;
|
guint n_rollsum;
|
||||||
|
|
@ -500,8 +501,9 @@ try_content_bsdiff (OstreeRepo *repo,
|
||||||
const char *from,
|
const char *from,
|
||||||
const char *to,
|
const char *to,
|
||||||
ContentBsdiff **out_bsdiff,
|
ContentBsdiff **out_bsdiff,
|
||||||
|
guint64 max_bsdiff_size_bytes,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
g_autoptr(GHashTable) from_bsdiff = NULL;
|
g_autoptr(GHashTable) from_bsdiff = NULL;
|
||||||
|
|
@ -521,8 +523,7 @@ try_content_bsdiff (OstreeRepo *repo,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* TODO: make this option configurable. */
|
if (g_bytes_get_size (tmp_to) + g_bytes_get_size (tmp_from) > max_bsdiff_size_bytes)
|
||||||
if (g_bytes_get_size (tmp_to) + g_bytes_get_size (tmp_from) > (200 * (1 << 20)))
|
|
||||||
{
|
{
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -1008,7 +1009,8 @@ generate_delta_lowlatency (OstreeRepo *repo,
|
||||||
if (!(opts & DELTAOPT_FLAG_DISABLE_BSDIFF))
|
if (!(opts & DELTAOPT_FLAG_DISABLE_BSDIFF))
|
||||||
{
|
{
|
||||||
if (!try_content_bsdiff (repo, from_checksum, to_checksum,
|
if (!try_content_bsdiff (repo, from_checksum, to_checksum,
|
||||||
&bsdiff, cancellable, error))
|
&bsdiff, builder->max_bsdiff_size_bytes,
|
||||||
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (bsdiff)
|
if (bsdiff)
|
||||||
|
|
@ -1228,6 +1230,8 @@ get_fallback_headers (OstreeRepo *self,
|
||||||
* are known:
|
* are known:
|
||||||
* - min-fallback-size: u: Minimume uncompressed size in megabytes to use fallback
|
* - 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-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
|
* - compression: y: Compression type: 0=none, x=lzma, g=gzip
|
||||||
* - bsdiff-enabled: b: Enable bsdiff compression. Default TRUE.
|
* - bsdiff-enabled: b: Enable bsdiff compression. Default TRUE.
|
||||||
* - verbose: b: Print diagnostic messages. Default FALSE.
|
* - verbose: b: Print diagnostic messages. Default FALSE.
|
||||||
|
|
@ -1246,6 +1250,7 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||||
OstreeStaticDeltaBuilder builder = { 0, };
|
OstreeStaticDeltaBuilder builder = { 0, };
|
||||||
guint i;
|
guint i;
|
||||||
guint min_fallback_size;
|
guint min_fallback_size;
|
||||||
|
guint max_bsdiff_size;
|
||||||
guint max_chunk_size;
|
guint max_chunk_size;
|
||||||
GVariant *metadata_source;
|
GVariant *metadata_source;
|
||||||
DeltaOpts delta_opts = DELTAOPT_FLAG_NONE;
|
DeltaOpts delta_opts = DELTAOPT_FLAG_NONE;
|
||||||
|
|
@ -1268,6 +1273,9 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||||
min_fallback_size = 4;
|
min_fallback_size = 4;
|
||||||
builder.min_fallback_size_bytes = ((guint64)min_fallback_size) * 1000 * 1000;
|
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))
|
if (!g_variant_lookup (params, "max-chunk-size", "u", &max_chunk_size))
|
||||||
max_chunk_size = 32;
|
max_chunk_size = 32;
|
||||||
builder.max_chunk_size_bytes = ((guint64)max_chunk_size) * 1000 * 1000;
|
builder.max_chunk_size_bytes = ((guint64)max_chunk_size) * 1000 * 1000;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
static char *opt_from_rev;
|
static char *opt_from_rev;
|
||||||
static char *opt_to_rev;
|
static char *opt_to_rev;
|
||||||
static char *opt_min_fallback_size;
|
static char *opt_min_fallback_size;
|
||||||
|
static char *opt_max_bsdiff_size;
|
||||||
static char *opt_max_chunk_size;
|
static char *opt_max_chunk_size;
|
||||||
static gboolean opt_empty;
|
static gboolean opt_empty;
|
||||||
static gboolean opt_disable_bsdiff;
|
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" },
|
{ "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 },
|
{ "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},
|
{ "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},
|
{ "max-chunk-size", 0, 0, G_OPTION_ARG_STRING, &opt_max_chunk_size, "Maximum size of delta chunks in megabytes", NULL},
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
@ -190,6 +192,9 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab
|
||||||
if (opt_min_fallback_size)
|
if (opt_min_fallback_size)
|
||||||
g_variant_builder_add (parambuilder, "{sv}",
|
g_variant_builder_add (parambuilder, "{sv}",
|
||||||
"min-fallback-size", g_variant_new_uint32 (g_ascii_strtoull (opt_min_fallback_size, NULL, 10)));
|
"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)
|
if (opt_max_chunk_size)
|
||||||
g_variant_builder_add (parambuilder, "{sv}",
|
g_variant_builder_add (parambuilder, "{sv}",
|
||||||
"max-chunk-size", g_variant_new_uint32 (g_ascii_strtoull (opt_max_chunk_size, NULL, 10)));
|
"max-chunk-size", g_variant_new_uint32 (g_ascii_strtoull (opt_max_chunk_size, NULL, 10)));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue