December 30, 2009

Branch Paths and Client View Best Practices

Product Branding
What's New

In recent visit with a customer, I ran across a situation that I thought warranted a blog entry. This user had a single directory where they were making all of their branches on their server, and the directories they were branching to this location contained 100,000 plus files per branch. As you can imagine, the number of files in this directory tree became large quickly. By itself, this wasn't a problem, but many users didn't want this directory in their view, so they added an exclusionary mapping to their workspace view to hide this directory. This is where the problem comes in. The way Perforce builds the client maps causes the server to end up scanning this excluded directory when the p4 dirs command is run on the workspace. Since the directory had so many files in it, it was causing the server to pause for ~15 seconds every time the p4 dirs command was run. It was an easy fix to solve the problem, but not an obvious one for the customer. The fix was to remove the exclusionary mapping, and use specific inclusionary mappings to get only the directories the users wanted in their workspace view. The p4 dirs command returned instantly with this change.  The customer also added some triggers to give users a default workspace view that did not use exclusionary mappings and also to warn users if they added an exclusionary mapping to their view.

So, in summary, their are two things to take away from this story:

  1. Don't use a single directory on the server for all your branches.
  2. Try to avoid exclusionary mappings when possible in your workspace views, and also in your protections table. It is much better to have many inclusionary mappings than a single exclusionary mapping.