diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2026-02-16 09:22:08 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2026-02-16 13:38:59 +0000 |
| commit | 84656fa6e54f6c19ce18b9fc40448a21f98a2d67 (patch) | |
| tree | ad07b1d771494b1a0904d9506e51eaa5770b909f /pkg/vcs/git.go | |
| parent | 9a9eeb63872d625a7653bbafdf3fb01fb717bb8d (diff) | |
pkg/vcs: speed up BaseForDiff
Only consider the commits of the last year.
It should be okay because, if the corresponding files haven't changed
recently, any branch will pass and this mechanism is not actually
needed.
Diffstat (limited to 'pkg/vcs/git.go')
| -rw-r--r-- | pkg/vcs/git.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/pkg/vcs/git.go b/pkg/vcs/git.go index dd9981873..f1311e312 100644 --- a/pkg/vcs/git.go +++ b/pkg/vcs/git.go @@ -764,10 +764,12 @@ type BaseCommit struct { Branches []string } -// BaseForDiff returns a list of commits that could have been the base commit -// for the specified git patch. -// The returned list is minimized to only contain the commits that are represented in different -// subsets of branches. +// BaseForDiff returns a list of commits that could have been the base +// commit for the specified git patch. +// For the purposes of optimization, the function only considers the +// commits that are newer than one year. +// The returned list is minimized to only contain the commits that are +// represented in different subsets of branches. func (git Git) BaseForDiff(diff []byte, tracer debugtracer.DebugTracer) ([]*BaseCommit, error) { // We can't just query git log with --find-object=HASH because that will only return // the revisions where the hashed content was introduced or removed, while what we actually @@ -784,6 +786,11 @@ func (git Git) BaseForDiff(diff []byte, tracer debugtracer.DebugTracer) ([]*Base "--no-renames", "-m", "-n", "500", + // With -m and -n 500, de facto we have scan all repo commits, which takes + // significant time on a Linux kernel checkout. + // If the blob hashes haven't been touched since one year, any reasonably + // fresh kernel branch will pass, so BaseForDiff is not really needed. + `--since="1 year ago"`, `--format=%H:%P`, } var fileNames []string |
