Sandcastle Performance improvements in February CTP

David Smith made some great observations regarding Sandcastle perf. issues on large assemblies at https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1125897&SiteID=1. We have been testing our code on Phoenix (https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1125897&SiteID=1) assemblies and here is what we found:

Prototype Style

VS2005 Style

Topic number

22289

32414

One big reflection file

6mins

16mins

One reflection file per assembly

5mins

13mins

One reflection file per assembly and not using MSDNWebService

4mins

8mins

Remarks:

1. Using ApplyVSDocModel for vs2005 transforms and AddOverloads for Prototype transform;

2. Memory peak value: one big file (600MB), one file per assembly (200MB).

3. The project tested was Phoenix (https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1125897&SiteID=1) assemblies.

 

As far as the difference between ApplyVSDocModel and AddOverloads, ApplyVSDocModel is doing what AddOverloads does plus a lot more, so it's to be expected that it will take significantly longer. We looked at the ApplyVSDocModel code and didn't see any obvious places to make perf improvements.

However when building phoenix documents, we found a performance issue during the CHM build process.

To create CHM contents file, we used the following command.

XslTransform /xsl:..\..\ProductionTransforms\ReflectionToChmContents.xsl reflection.xml /arg:html=Output\html /out:Output\test.hhc

 

In ReflectionToChmContents.xsl, xsl:document() is used to get topic title.

<xsl:value-of select="document(concat($html,'/', file/@name, '.htm'),.)/html/head/title"/>

         <xsl:value-of select="document(concat($html,'/', key('index',$overloadId)/file/@name, '.htm'),.)/html/head/title"/>

 

When applying this xsl, the xsltransform consumed all system memory. For building Phoenix documentation, the process took an hour to create this hhc file because the cache mechanism of xsl:document(), all html files are loaded into memory and not released.

 

In February CTP we have addressed this issue by creating a user defined function to replace xsl:document().

 

<xsl:stylesheet version="1.0"

    xmlns:xsl="https://www.w3.org/1999/XSL/Transform"

    xmlns:msxsl="urn:schemas-microsoft-com:xslt"

xmlns:ddue="https://ddue.schemas.microsoft.com/authoring/2003/5">

 

 <msxsl:script language="C#" implements-prefix="ddue">
<msxsl:using namespace="System.Xml" />
<msxsl:using namespace="System.Xml.XPath" />
<![CDATA[
public static string getTitle(string fileName) {
XPathDocument doc = new XPathDocument(fileName);
XPathNavigator node = doc.CreateNavigator().SelectSingleNode("/html/head/title");
if (node != null)
return node.Value;
else
return String.Empty;
}
]]>
</msxsl:script>

 

This function is used at:

  <xsl:value-of select="ddue:getTitle(concat($html,'/', @file, '.htm'))"/>

 

The perf improvement is lot better with February CTP. For phoenix project, it takes about 4 minutes to generate hhc file compared to 1 hour before.