repo: Further optimize ostree_repo_list_objects_set()

In a prior change we discovered that for bad historical reasons
libostree was returning a mapping "object type+checksum" => "metadata"
but the "metadata" was redundant and pointless.

Optimize the prune API to use a (currently internal) object listing
API which returns a set, not a map.  This allows `GHashTable` to
avoid allocating a separate array for the values, neatly cutting
memory usage in half (from ~13MB to ~6MB) on my test case of a
dry-run prune of a FCOS build.
This commit is contained in:
Colin Walters committed 2022-06-08 10:18:55 -04:00
1 parent ef114db341
commit a71915e436
3 files changed
+84 -46

No files matched your search

+4 -10
View File
@@ -280,15 +280,8 @@ repo_prune_internal (OstreeRepo *self,
g_autoptr(GHashTable) reachable_owned = g_hash_table_ref (options->reachable);
data.reachable = reachable_owned;
GLNX_HASH_TABLE_FOREACH_KV (objects, GVariant*, serialized_key, GVariant*, objdata)
GLNX_HASH_TABLE_FOREACH (objects, GVariant*, serialized_key)
{
gboolean is_loose;
g_variant_get_child (objdata, 0, "b", &is_loose);
if (!is_loose)
continue;
if (!maybe_prune_loose_object (&data, options->flags, serialized_key,
cancellable, error))
return FALSE;
@@ -444,8 +437,9 @@ ostree_repo_prune (OstreeRepo *self,
return FALSE;
}
if (!ostree_repo_list_objects (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
&objects, cancellable, error))
objects = ostree_repo_list_objects_set (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
cancellable, error);
if (!objects)
return FALSE;
if (!refs_only)