lib/prune: speed up pruning by retrieving only commits
After landing the new --commit-only functionality, we still noticed exceedingly long pruning times in large repos. Lets add an optimization that will only retrieve commit objects when --commit-only flag is used.
This commit is contained in:
parent
502ad96af2
commit
a984871237
|
|
@ -189,7 +189,6 @@ _ostree_repo_prune_tmp (OstreeRepo *self,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ostree_repo_prune_static_deltas:
|
* ostree_repo_prune_static_deltas:
|
||||||
* @self: Repo
|
* @self: Repo
|
||||||
|
|
@ -437,8 +436,17 @@ ostree_repo_prune (OstreeRepo *self,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
objects = ostree_repo_list_objects_set (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
|
if (commit_only)
|
||||||
|
{
|
||||||
|
if (!ostree_repo_list_commit_objects_starting_with (self, "", &objects, cancellable, error))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objects = ostree_repo_list_objects_set (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
|
||||||
cancellable, error);
|
cancellable, error);
|
||||||
|
}
|
||||||
|
|
||||||
if (!objects)
|
if (!objects)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
@ -508,9 +516,20 @@ ostree_repo_prune_from_reachable (OstreeRepo *self,
|
||||||
if (!lock)
|
if (!lock)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
g_autoptr(GHashTable) objects =
|
g_autoptr(GHashTable) objects = NULL;
|
||||||
ostree_repo_list_objects_set (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
|
OstreeRepoPruneFlags flags = options->flags;
|
||||||
cancellable, error);
|
gboolean commit_only = (flags & OSTREE_REPO_PRUNE_FLAGS_COMMIT_ONLY) > 0;
|
||||||
|
if (commit_only)
|
||||||
|
{
|
||||||
|
if (!ostree_repo_list_commit_objects_starting_with (self, "", &objects, cancellable, error))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objects =
|
||||||
|
ostree_repo_list_objects_set (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
|
||||||
|
cancellable, error);
|
||||||
|
}
|
||||||
if (!objects)
|
if (!objects)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1261,7 +1261,7 @@ void ostree_repo_commit_traverse_iter_cleanup (void *p);
|
||||||
* OstreeRepoPruneFlags:
|
* OstreeRepoPruneFlags:
|
||||||
* @OSTREE_REPO_PRUNE_FLAGS_NONE: No special options for pruning
|
* @OSTREE_REPO_PRUNE_FLAGS_NONE: No special options for pruning
|
||||||
* @OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE: Don't actually delete objects
|
* @OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE: Don't actually delete objects
|
||||||
* @OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY: Do not traverse individual commit objects, only follow refs
|
* @OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY: Do not traverse individual commit objects, only follow refs for reachability calculations
|
||||||
* @OSTREE_REPO_PRUNE_FLAGS_COMMIT_ONLY: Only traverse commit objects. (Since 2022.2)
|
* @OSTREE_REPO_PRUNE_FLAGS_COMMIT_ONLY: Only traverse commit objects. (Since 2022.2)
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue