API Get is slower than Fortress client get latest version

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
fryhard
Posts: 6
Joined: Wed May 27, 2009 7:12 am

API Get is slower than Fortress client get latest version

Post by fryhard » Wed May 27, 2009 7:26 am

Hey, I am currently writing a small application to make use of the Fortress API and get latest version of all files for all repositories.

My code currently looks something like this:

Code: Select all

 
VaultRepositoryInfo[] repositoryInfos = ServerOperations.ProcessCommandListRepositories();
foreach (VaultRepositoryInfo info in repositoryInfos)
{
   ServerOperations.SetRepository(info);
   GetOperations.ProcessCommandGetToLocationOutsideWorkingFolder(new string[] {"$"}, new GetOptions() {MakeWritable = MakeWritableType.MakeAllFilesWritable, Merge = MergeType.AttemptAutomaticMerge, PerformDeletions = PerformDeletionsType.DoNotRemoveWorkingCopy, Recursive = true, SetFileTime = SetFileTimeType.Current}, "C:/workspace/");
}
The solution works with each of the repository's files being got to their relevant folder in C:\Workspace.

The problem that I have is that it is taking awfully long to do this. For 90MB of data it is taking over 45 seconds. This may seem fine, but there will be 60 repositories by the end of the setup and we can not wait 45 mins for them to update.
  • I first thought that the problem was only happening on first get (the first time the files are copied form the server, but it seems to be consistent in its slowness.
  • I notice that the Fortress client is able to finish a get latest version in 1 second. How does it do this?
I get the feeling that the client is being sneaky and only fetching files that have been changed. How could I set this up using the API?

Thanks in advance.
Brendan

shannon

Re: API Get is slower than Fortress client get latest version

Post by shannon » Wed May 27, 2009 7:51 am

The "sneakiness" comes from using working folders :)

The method you're using is a get to a non-working folder - no working folder means no cache data, so it gets everything every time.

Give this a try:

ServerOperations.SetRepository(info);
ServerOperations.SetWorkingFolder("$", "C:/workspace/" );
GetOperations.ProcessCommandGet(new string[] {"$"}, new GetOptions() {MakeWritable = MakeWritableType.MakeAllFilesWritable, Merge = MergeType.AttemptAutomaticMerge, PerformDeletions = PerformDeletionsType.DoNotRemoveWorkingCopy, Recursive = true, SetFileTime = SetFileTimeType.Current});

Of course, it will always be slow the first time, when it gets everything and creates the cache data. After that it should utilize the cache data and only get what has changed.

fryhard
Posts: 6
Joined: Wed May 27, 2009 7:12 am

Re: API Get is slower than Fortress client get latest version

Post by fryhard » Wed May 27, 2009 11:24 pm

Thanks so much for the answer! It works great...

As you said the first GET takes a while, but thereafter we are down to 1 second and after that, less than a second.

A question on the working folders cache: I assume it is being stored on the client PC (The PC that run the code from your example). When this PC is reset is the cache lost or would it remain indefinitely? Where around is the cache stored (would we need to grant special rights to the user running the application?)

I know these are random questions, but I want to get a full picture of what is happening.

Thanks again
Brendan

shannon

Re: API Get is slower than Fortress client get latest version

Post by shannon » Thu May 28, 2009 7:19 am

If you look in the GUI client options (Tools->Options->Local Files->Cache Location), you can see/change the cache location for each user. Both your main cache and your state/baseline files are important. I don't think you'd need to give special permissions if you're using the defaults, but if you decide on a custom location, you might.

What do you mean by reset the PC? If we're talking about just restarting, the cache will remain.

Post Reply