libgit2 / libgit2sharp

Git + .NET = ❤
http://libgit2.github.com
MIT License
3.2k stars 889 forks source link

Why Pull operations is so Slow? #1527

Open Stellacci opened 6 years ago

Stellacci commented 6 years ago

Hi all, I'm new and I'm developing using this library. I have some problem with pull operations. This is my code:

 Debug.Write("Pulling branch. . .");
            LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions();
            options.FetchOptions = new FetchOptions();
            options.FetchOptions.CredentialsProvider = new CredentialsHandler(
                (url, usernameFromUrl, types) =>
                    new UsernamePasswordCredentials()
                    {
                        Username = this.Username,
                        Password = this.Password
                    });
            Signature author = new Signature(this.Username, this.EmailUser, DateTime.Now);
            Commands.Pull(Repo, author, options);
            Debug.Write("Pulling done.");

I don't uderstand why Pulling ONE FILE (txt 1kb) is so SLOW. Is there anyone help me?

ethomson commented 6 years ago

You've given literally no data to work with that might answer your question. What do you consider "slow"? How fast does git work? What version of git are you comparing against? Is this a large repository? Are you transferring the same data with both clients? Are you sure? You don't have any callbacks to show how many objects you're fetching...

If you can provide a sample repository that illustrates that this is fast in one scenario and slow in another, that would be helpful. Otherwise, there is no way to answer your question.

Stellacci commented 6 years ago

If I add a simple .txt file in the remote repository, I expect that the pulling of ONLY THAT file is fast. Instead it takes about 10-15 to finish the pull.

ethomson commented 6 years ago

Yes, I understand how pull works. You haven't answered any of my questions.

Stellacci commented 6 years ago

Ok, sorry. -I'm using libgit2sharp version 0.24 -The repository is very large -I'm not trasnferring any data

ethomson commented 6 years ago

The repository is very large

How large are we talking? How many branches and tags do you have?

How long does git take to do the same pull?

ethomson commented 6 years ago

To clarify: the problem isn't how much data is being transferred, it's walking the graph to figure out what needs to be transferred.

Stellacci commented 6 years ago
ethomson commented 6 years ago

OK, and it takes LibGit2Sharp to take 10-15 seconds or minutes? (There's no unit in your comment above.)

Stellacci commented 6 years ago

Minutes (I forget to write it)

Stellacci commented 6 years ago

Do you have any idea?

ethomson commented 6 years ago

Not offhand, no. I suspect that libgit2 is walking much more of the graph than is needed, but I don't know why it would be doing that.

carlosmn commented 6 years ago

Are you doing this over the network? How are you running git? Are they equivalent calls?

Stellacci commented 6 years ago

@carlosmn Yes, I do over the network. But I think that my code is wrong maybe. Is it correct or I can add some fixes?

Stellacci commented 6 years ago

Anything else?

Stellacci commented 6 years ago

@carlosmn Do you have some idea about my problem?

ethomson commented 6 years ago

How are you running git?

Stellacci commented 6 years ago

With "GitExtension" tool. But this does not explain why the pull in Libgit2sharp is slow