<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jabbering Giraffe &#187; perforce</title>
	<atom:link href="http://happygiraffe.net/blog/tag/perforce/feed/" rel="self" type="application/rss+xml" />
	<link>http://happygiraffe.net/blog</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 20:49:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>The Perforce Perspective</title>
		<link>http://happygiraffe.net/blog/2009/11/09/the-perforce-perspective/</link>
		<comments>http://happygiraffe.net/blog/2009/11/09/the-perforce-perspective/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 19:59:28 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[perforce]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1644</guid>
		<description><![CDATA[I&#8217;m a long time user of subversion, and more recently git. Coming to Google, however, everything&#8217;s based around perforce. I&#8217;m still new enough to it, that I don&#8217;t want to criticise it, merely contrast my experiences with it. The first &#8230; <a href="http://happygiraffe.net/blog/2009/11/09/the-perforce-perspective/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a long time user of <a href="http://subversion.tigris.org/">subversion</a>, and more recently <a href="http://git-scm.org/">git</a>.  Coming to Google, however, everything&#8217;s based around <a href="http://www.perforce.com/">perforce</a>.  I&#8217;m still new enough to it, that I don&#8217;t want to criticise it, merely contrast my experiences with it.</p>
<p>The first thing that I noticed with perforce (<code>p4</code>) is quite how server-based it is.  Subversion (and CVS) is often criticised for leaving lots of &#8220;turds&#8221; around: <code>.svn</code> or <code>CVS</code> directories.  They&#8217;re just clutter that you don&#8217;t want to be bothered with.  With perforce however, <em>everything</em> lives on the server.  There is almost no data stored on the client side (perhaps just a <code>.p4config</code> file).  Everything you do has to talk to the server.</p>
<p>The next surprise was how things are checked out.  In subversion, you usually check out the trunk of a project, or a branch.  You can do that in perforce, but it&#8217;s a great deal more flexible.  You supply a client spec, which is a small text file describing a mapping from the server&#8217;s directory structure to your own workspace.  e.g.</p>
<pre class='perforce-client'>
Client: myproject-client

Root: /home/dom/myproject

Views:
  //depot/myproject/...  //myproject-client/myproject/...
  -//depot/myproject/bigdata/... //myproject-client/myproject/bigdata/...
</pre>
<p>In this example, I&#8217;ve checked out all of <code>myproject</code>, except I&#8217;ve also removed some big data which I don&#8217;t need for my development.  You can create a client workspace which is composed of any part (or parts) of your repository.  Unsurprisingly, this is both a blessing and a curse.  You can create very complicated setups using these somewhat ephemeral client specs.  But they&#8217;re not (by default) versioned, so they&#8217;re really easy to lose.  I&#8217;ve also found it very easy to make small mistakes which mean the wrong bits of projects are checked out (or no bits).  If you&#8217;re new to a project, figuring out the correct client spec is one of the first hurdles you&#8217;ll come across.</p>
<p>Once you&#8217;ve got some code checked out, it&#8217;s not too dissimilar to other version control systems.  The most irritating thing that I came across was <code>p4</code>&#8216;s inability to detect added files.  So, if I create a file <code>…/myproject/foo.txt</code> and run <code>p4 pending</code>, it says &#8220;no change.&#8221;  You have to explicitly run <code>p4 add</code>.  This is terrible — it&#8217;s really easy to forget add files.  You can convince perforce to list these files, but it&#8217;s not trivial:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #660033;">-type</span> f <span style="color: #000000; font-weight: bold;">|</span> p4 <span style="color: #660033;">-x</span> - files <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'/ - no such file/{print $1}'</span></pre></div></div>

<p>One feature I quite like is the ability to have &#8220;pending changelists.&#8221;  A <em>changelist</em> is perforce&#8217;s equivalent of a commit in subversion.  You can create a <em>pending changelist</em>, which essentially allows you to build up a commit a little bit at a time, somewhat like git&#8217;s index.  But even though you can have multiple pending changelists in a single client, you are still restricted in that a given file can only be in one of them.  Personally, I find the git index more useful.  Plus, when you submit a pending changelist, it gets assigned a new changelist number.  This can make them difficult to track.</p>
<p>The critical feature for perforce is it&#8217;s integration (merging) support.  Whilst I&#8217;ve done a few <code>p4 integrate</code>s, I&#8217;ve not got the full hang of it yet.  But it&#8217;s clearly far in advance of svn&#8217;s merging.</p>
<p>Internally, perforce is built upon two things:</p>
<ol>
<li> A collection of RCS <code>*,v</code> files.
<li> A few database files to coordinate metadata.
</ol>
<p>This architecture is noticeable: as soon as you look at the file log, you can see that each file has its own individual version number.</p>
<p>Over the years, Google have built up tools to work around many of these issues.  There&#8217;s a nice discussion of perforce and how it&#8217;s used at Google in the <a href="http://lwn.net/Articles/357658/#Comments">comments</a> of the <a href="http://lwn.net/">LWN</a> article <a href="http://lwn.net/Articles/357658/">KS2009: How Google uses Linux</a> (which is a fascinating read in and of itself).</p>
<p>In case you&#8217;re interested in some of the challenges of running perforce at the scale of Google, it&#8217;s worth checking out some of the papers that have been presented at the perforce user conferences:</p>
<ul>
<li><a href="http://www.perforce.com/perforce/conferences/eu/2006/presentations/Google.pdf">Performance and Database Locking at Large Perforce Sites</a> (2006)
<li><a href="http://www.perforce.com/perforce/conferences/us/2007/presentations/DBloch_Life_on_the_Edge2007_paper.pdf">Life on the Edge: Monitoring and Running A Very Large Large Perforce Installation</a> (2007)
<li><a href="http://www.perforce.com/perforce/conferences/us/2009/Presentations/Wright-Disaster_Recovery-paper.pdf">Perforce Disaster Recovery at Google</a> (2009)
</ul>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2009/11/09/the-perforce-perspective/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

