From 204fad4239f4f3821e5079bc016a81545761de66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Due=C3=B1as?= Date: Tue, 3 Dec 2024 14:36:36 +0100 Subject: [PATCH] [git] Update references changed on the remote repo only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When repositories are synched, the backend needs to update the local references to the ones set on the remote repository. The backend processed all the references, including those up to date. This made the synchronization very slow. With this commit, only the references that were updated on the remote repository will be modified locally. We have improved the performance by 2. Repositories are in sync two or more times than before. Signed-off-by: Santiago Dueñas --- perceval/backends/core/git.py | 6 ++++++ .../unreleased/git-sync-perfomance-improved.yml | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 releases/unreleased/git-sync-perfomance-improved.yml diff --git a/perceval/backends/core/git.py b/perceval/backends/core/git.py index 3b962353a..a2b4a9180 100644 --- a/perceval/backends/core/git.py +++ b/perceval/backends/core/git.py @@ -1304,6 +1304,8 @@ def _update_references(self, refs): self._update_ref(old_ref, delete=True) # Update new references + current_refs = {ref.refname: ref.hash for ref in self._discover_refs()} + for new_ref in refs: refname = new_ref.refname @@ -1315,6 +1317,10 @@ def _update_references(self, refs): logger.debug("Reference %s not needed; ignored for updating in sync process", refname) continue + elif refname in current_refs and new_ref.hash == current_refs[refname]: + logger.debug("Reference %s already up to date in sync process", + refname) + continue else: self._update_ref(new_ref) diff --git a/releases/unreleased/git-sync-perfomance-improved.yml b/releases/unreleased/git-sync-perfomance-improved.yml new file mode 100644 index 000000000..abc206a81 --- /dev/null +++ b/releases/unreleased/git-sync-perfomance-improved.yml @@ -0,0 +1,14 @@ +--- +title: Git sync improved for `--latest-items` flag +category: performance +author: Santiago Dueñas +issue: null +notes: > + The speed updating a git repository when `--lates-items` + is set was very poor. The main problem was when the + references were updated to the new hashes. All the + active refs on the repository were modified, even when + they were up-to-date. Now, only references updated + on the remote repository are modified on the local one. + Repositories are synched 2 times faster than before. +