Skip to content

repo.Commits.QueryBy(filename) slow on large repos #1705

Open
@tster123

Description

@tster123

Reproduction steps

1): Clone a large repo
2): run this function on that repo with some random file:

public IEnumerable<string> TestSlow(string filename)
{
    using (var repo = new Repository(repoRoot))
    {
        string path = filename.Substring(repoRoot.Length + 1).Replace("\\", "/");
        foreach (LogEntry entry in repo.Commits.QueryBy(path))
        {
            yield return entry.Commit.Author.ToString();
        }
    }
}
  1. run this command on the same file: "git log --follow --oneline -- "

Expected behavior

I expect similar time to be taken by TestSlow and the git log command above

Actual behavior

The git log command finishes in about 1.6 ms on my repo
The TestSlow command takes about 70 seconds.

Here is what I see in my profiler:
profiler view

Version of LibGit2Sharp (release number or SHA1)

0.27.0-preview-0017
0.26.1
0.24.1

Operating system(s) tested; .NET runtime tested

.NET Framework 4.7.2 on Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions