From 2c109d3c5bd8dc88d75838032a1eb48b2469753c Mon Sep 17 00:00:00 2001 From: zaits07 Date: Tue, 25 Aug 2026 14:43:41 +0300 Subject: [PATCH] Update git.rb Fast exit from update_cache if repo not changed since cached. I need last change date in oxidized-web node list. I patched oxidize-web and see last change date in node list according to last version from git repo date. But my list of 200 nodes refreshes by 30 sec. I found that almost time spent in git.update_cache. Specifically in code ` walker = Rugged::Walker.new(repo) walker.sorting(Rugged::SORT_DATE) walker.push(repo.head.target.oid)` And it called on every node, regardless that i have only one repo and it cached after first node. --- lib/oxidized/output/git.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/oxidized/output/git.rb b/lib/oxidized/output/git.rb index f9836493f..fe3722b53 100644 --- a/lib/oxidized/output/git.rb +++ b/lib/oxidized/output/git.rb @@ -156,6 +156,13 @@ def self.update_cache(repo_path) end repo = Rugged::Repository.new repo_path + + # Early exit if repo not changed since cached + current_head = repo.head.target.oid + if current_head == @gitcache[repo_path][:last_commit] + Oxidized.logger.debug { "git.update_cache hit, skipping walker for #{repo_path}" } + return + end walker = Rugged::Walker.new(repo) walker.sorting(Rugged::SORT_DATE)