Skip to content

Conversation

spencerschrock
Copy link
Member

@spencerschrock spencerschrock commented Mar 17, 2025

What kind of change does this PR introduce?

optimization

What is the current behavior?

We already doing a shallow clone, but go-git fetches all tags from the remote by default. We don't need them for this operation, we just care about the files at HEAD (or whatever commit is requested).

What is the new behavior (if this is a feature change)?**

Don't fetch tags. This performance optimization results in a 3x speedup on my machine when analyzing the ossf/scorecard repository with --file-mode git. It practically gets performance up to --file-mode archive levels

See upstream discussion here

Before: 29.974s
After: 8.644s
(archive): 5.173s

  • Tests for the changes have been added (for bug fixes/features)
    NONE

Which issue(s) this PR fixes

Special notes for your reviewer

scdiff tests pass (though the workflow command we have isn't configured to do this)

With a slightly modified scdiff to use --file-mode git, the difference is 2x or so:

Before: 4m 11s
After: 2m 21s
(archive mode): 2m 15s

Does this PR introduce a user-facing change?

For user-facing changes, please add a concise, human-readable release note to
the release-note

(In particular, describe what changes users might need to make in their
application as a result of this pull request.)

Improved the performance of `--file-mode git`

We are only concerned with the files at the requested commit, and were
already doing a shallow clone. This performance optimization results in
a 3x speedup on my machine when analyzing the ossf/scorecard repository
with --file-mode git.

Signed-off-by: Spencer Schrock <sschrock@google.com>
@spencerschrock spencerschrock requested a review from a team as a code owner March 17, 2025 18:47
@spencerschrock spencerschrock requested review from justaugustus and raghavkaul and removed request for a team March 17, 2025 18:47
Copy link

codecov bot commented Mar 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.38%. Comparing base (353ed60) to head (ae4e030).
Report is 143 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4563      +/-   ##
==========================================
+ Coverage   66.80%   68.38%   +1.58%     
==========================================
  Files         230      249      +19     
  Lines       16602    18822    +2220     
==========================================
+ Hits        11091    12872    +1781     
- Misses       4808     5097     +289     
- Partials      703      853     +150     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@raghavkaul
Copy link
Contributor

Great improvement! LGTM.

@spencerschrock spencerschrock enabled auto-merge (squash) March 24, 2025 21:07
@spencerschrock spencerschrock merged commit dacd25a into ossf:main Mar 24, 2025
38 checks passed
@spencerschrock spencerschrock deleted the git-clone branch March 24, 2025 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants