简体   繁体   中英

Performance issue when querying source control permissions with TFS SDK

I have a performance issue with TFS. The issue seems to be independent from the version, I encountered it with TFS 2012 and TFS 2010.

I'm working on a permission management tool for TFS. When the user selects a team project collection and a specific project, I initiate a query to get all source control item permissions, and I build a cache. During the development I tested with small, local projects, and I didn't notice any performance problems, but in a little bit larger projects (5000+ files) the query gets really slow.

I use VersionControlServer.GetPermissions method for this query.

I tried to call it giving only the root item with RecursionType.Full , but then I don't receive all item permissions, only those, for which the authenticated user has explicit permissions (I guess).

So, I call the method giving all items of the project and the recursion is set to RecursionType.None . Here are the important lines of the code:

    ItemSet projectItems = VersionControlServer
                    .GetItems(projectRootItem, RecursionType.Full);
    IEnumerable<string> serverItems = projectItems.Items
                                            .Select(i => i.ServerItem);
    IEnumerable<ItemSecurity> itemSecurities = VersionControlServer
                    .GetPermissions(serverItems.ToArray(), RecursionType.None);

I would expect the last line to make a single call to TFS, but when I profiled the application, I saw that there were an unreasonable number of HTTP requests, 11993 requests for 7800 files, and the method was running for about 2 minutes.

I spent quite a lot of time trying to find out the reason for this behavior without success. I also couldn't find a good alternative solution inTFS SDK .

Any help would be much appreciated!

I have one thing.

Your query is terribly slow because first, you take all projectItems.Items to a list and then, when you pass it as an argument to the method VersionControlService.GetPermissions() you convert it to an array using ToArray() , which causes copying all the items in the list.

I suggest that you do not convert items to List . Use IEnumerable<string> instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM