static delta generation: Separate max chunk size from min fallback size
There is no particular reason these have to be the same. https://bugzilla.gnome.org/show_bug.cgi?id=721799
This commit is contained in:
parent
6bbfa5f85a
commit
638431045c
|
|
@ -44,7 +44,8 @@ typedef struct {
|
|||
GPtrArray *parts;
|
||||
GPtrArray *fallback_objects;
|
||||
guint64 loose_compressed_size;
|
||||
guint64 max_usize_bytes;
|
||||
guint64 min_fallback_size_bytes;
|
||||
guint64 max_chunk_size_bytes;
|
||||
} OstreeStaticDeltaBuilder;
|
||||
|
||||
static void
|
||||
|
|
@ -121,7 +122,7 @@ process_one_object (OstreeRepo *repo,
|
|||
|
||||
/* Check to see if this delta is maximum size */
|
||||
if (current_part->objects->len > 0 &&
|
||||
current_part->payload->len + content_size > builder->max_usize_bytes)
|
||||
current_part->payload->len + content_size > builder->max_chunk_size_bytes)
|
||||
{
|
||||
*current_part_val = current_part = allocate_part (builder);
|
||||
}
|
||||
|
|
@ -296,7 +297,7 @@ generate_delta_lowlatency (OstreeRepo *repo,
|
|||
NULL, &uncompressed_size,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
if (uncompressed_size > builder->max_usize_bytes)
|
||||
if (uncompressed_size > builder->min_fallback_size_bytes)
|
||||
fallback = TRUE;
|
||||
|
||||
if (fallback)
|
||||
|
|
@ -432,7 +433,8 @@ get_fallback_headers (OstreeRepo *self,
|
|||
*
|
||||
* The @params argument should be an a{sv}. The following attributes
|
||||
* are known:
|
||||
* - max-usize: u: Maximum size in megabytes of a delta part
|
||||
* - min-fallback-size: u: Minimume uncompressed size in megabytes to use fallback
|
||||
* - max-chunk-size: u: Maximum size in megabytes of a delta part
|
||||
* - compression: y: Compression type: 0=none, x=lzma, g=gzip
|
||||
*/
|
||||
gboolean
|
||||
|
|
@ -448,7 +450,8 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
|||
gboolean ret = FALSE;
|
||||
OstreeStaticDeltaBuilder builder = { 0, };
|
||||
guint i;
|
||||
guint max_usize;
|
||||
guint min_fallback_size;
|
||||
guint max_chunk_size;
|
||||
GVariant *metadata_source;
|
||||
guint64 total_compressed_size = 0;
|
||||
guint64 total_uncompressed_size = 0;
|
||||
|
|
@ -465,9 +468,13 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
|||
builder.parts = g_ptr_array_new_with_free_func ((GDestroyNotify)ostree_static_delta_part_builder_unref);
|
||||
builder.fallback_objects = g_ptr_array_new_with_free_func ((GDestroyNotify)g_variant_unref);
|
||||
|
||||
if (!g_variant_lookup (params, "max-usize", "u", &max_usize))
|
||||
max_usize = 32;
|
||||
builder.max_usize_bytes = ((guint64)max_usize) * 1000 * 1000;
|
||||
if (!g_variant_lookup (params, "min-fallback-size", "u", &min_fallback_size))
|
||||
min_fallback_size = 4;
|
||||
builder.min_fallback_size_bytes = ((guint64)min_fallback_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;
|
||||
|
||||
if (!ostree_repo_load_variant (self, OSTREE_OBJECT_TYPE_COMMIT, to,
|
||||
&to_commit, error))
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ static char *opt_from_rev;
|
|||
static char *opt_to_rev;
|
||||
static char **opt_key_ids;
|
||||
static char *opt_gpg_homedir;
|
||||
static char *opt_max_usize;
|
||||
static char *opt_min_fallback_size;
|
||||
static char *opt_max_chunk_size;
|
||||
static gboolean opt_empty;
|
||||
|
||||
#define BUILTINPROTO(name) static gboolean ot_static_delta_builtin_ ## name (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
|
|
@ -55,7 +56,8 @@ static GOptionEntry generate_options[] = {
|
|||
{ "to", 0, 0, G_OPTION_ARG_STRING, &opt_to_rev, "Create delta to revision REV", "REV" },
|
||||
{ "gpg-sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "GPG Key ID to sign the delta with", "key-id"},
|
||||
{ "gpg-homedir", 0, 0, G_OPTION_ARG_STRING, &opt_gpg_homedir, "GPG Homedir to use when looking for keyrings", "homedir"},
|
||||
{ "max-usize", 'u', 0, G_OPTION_ARG_STRING, &opt_max_usize, "Maximum uncompressed size in megabytes", 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-chunk-size", 0, 0, G_OPTION_ARG_STRING, &opt_max_chunk_size, "Maximum size of delta chunks in megabytes", NULL},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
|
@ -184,9 +186,12 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab
|
|||
goto out;
|
||||
|
||||
parambuilder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
|
||||
if (opt_max_usize)
|
||||
if (opt_min_fallback_size)
|
||||
g_variant_builder_add (parambuilder, "{sv}",
|
||||
"max-usize", g_variant_new_uint32 (g_ascii_strtoull (opt_max_usize, NULL, 10)));
|
||||
"min-fallback-size", g_variant_new_uint32 (g_ascii_strtoull (opt_min_fallback_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)));
|
||||
|
||||
g_print ("Generating static delta:\n");
|
||||
g_print (" From: %s\n", from_resolved ? from_resolved : "empty");
|
||||
|
|
|
|||
Loading…
Reference in New Issue