LibrarySites.Banner

Maximize Sitecore Developer Productivity

This blog post contains some suggestions that I believe can help to maximize productivity for developers working with the Sitecore ASP.NET web Content Management System (CMS) and Experience Platform (XP).

Table of Contents

Continued Education

Proper developer orientation is critical to a successful Sitecore implementation. Beyond training and documentation, to increase productivity with an ever-evolving product in a relentless problem space, Sitecore developers should monitor developments in the field. The number of places to obtain information about Sitecore has become staggering. Trying to keep the list short, here are what I consider to be some of the most important resources. You can also follow #sitecore on twitter.>

Tools

To optimize performance, Sitecore developers should work with solid-state drives. I highly recommend software tools including at least Sitecore Rocks and Team Development for Sitecore (TDS) by Hedgehog Development. Sitecore developers should also consider available accelerators.

Disable SPEAK Precompilation

While tools are important, SPEAK precompilation may be the most important issue described in this blog post. In general, the default Sitecore configuration supports developers, and mainly needs alteration for security, scalability, and otherwise in production environments. One exception may be SPEAK. By default, Sitecore precompiles SPEAK applications at each application initialization. This can improve performance for users in the production content management environment, but presents unnecessary overhead in content delivery environments, and especially for developers who need to restart ASP.NET frequently due to compilation, configuration changes, package installations, or otherwise.

See the blog post by Sitecore MVP Kam Figy in the Resources section at the end of this page for more information. To prevent precompilation, Kam suggests that you can set the optimizeCompilations attribute of the /configuration/system.web/compilation element in the /web.config file to true. Because this element is not within the /configuration/sitecore element, you cannot use a Web.config config include file to implement this change.

That did not seem to work for me. A Web.config include file to disable the initialize pipeline processor responsible for precompilation worked best for me. Actually, there are two instances of this processor to disable, one from the /App_Config/Include/Sitecore.Speak.config Web.config include file and one in the /App_Config/Include/ContentTesting/Sitecore.Content.Testing.config Web.config include file. We need to delete both, but due to the automatic order of processing Web.config include files, we also need to put our Web.confilg file in a subdirectory that follows ContentTesting alphabetically.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <initialize>
        <processor
          type="Sitecore.Pipelines.Initialize.PrecompileSpeakViews, Sitecore.Speak.Client">
          <patch:delete />
        </processor>
        <processor
          type="Sitecore.Pipelines.Initialize.PrecompileSpeakViews, Sitecore.Speak.Client">
          <patch:delete />
        </processor>
      </initialize>
    </pipelines>
  </sitecore>
</configuration>

Visual Studio Configuration

What I see as section 2.4.8 (How to Optimize Visual Studio Performance) of Sitecore Presentation Component Cookbook contains some suggestions for tuning Visual Studio, especially around startup. Because I wrote them and the new Sitecore documentation site makes this document obsolete, I think it is acceptable for me to paste that content here. These may be obsolete; I have not even tried them with VS2012, which is the version I still use.

2.4.8 How to Optimize Visual Studio Performance

This section provides tips to improve the performance of Visual Studio.

Before closing Visual Studio, close user interface components that do not need to be open the next time you start the application.

To access the Visual Studio Options dialog:

  • In Visual Studio, click the Tools menu, and then click Options.

To disable Visual Studio RSS feeds:

  1. In the Visual Studio Options dialog, expand Environment, and then click Startup.
  2. In the Visual Studio Options dialog, clear Start Page news channel.
  3. In the Visual Studio Options dialog, disable Download content every.

To disable the start page:

  1. In the Visual Studio Options dialog, expand Environment, and then click Startup.
  2. In the Visual Studio Options dialog, for At Startup drop-down, select Show empty environment.

Note

To show the Visual Studio start page, in Visual Studio, click the View menu, then click Other Windows, and then click Start Page.

To disable the Visual Studio splash screen:

  1. In the Windows Desktop, right-click the shortcut you use to start Visual Studio, and then click Properties. A properties dialog appears for the shortcut.
  2. In the shortcut properties dialog, click the Shortcut tab.
  3. In the shortcut properties dialog, on the Shortcut tab, add the /nosplash command line option to Target. For example:

"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /nosplash.

To disable animation:

  1. In the Visual Studio Options dialog, click Environment.
  2. In the Visual Studio Options dialog, clear the Animate environment tools checkbox.

To disable change tracking:

  1. In the Visual Studio Options dialog, click Text Editor.
  2. In the Visual Studio Options dialog, disable Track changes.

To turn off active item tracking:

  1. In the Visual Studio Options dialog, click Projects and Solutions.
  2. In the Visual Studio Options dialog, disable Track Active Item in Solution Explorer.

To turn off AutoToolboxPopulate:

  1. In the Visual Studio Options dialog, click Windows Forms Designer.
  2. In the Visual Studio Options dialog, under Toolbox, set AutoToolboxPopulate to False.

To cause Visual Studio to open Layouts and Subalyouts in source code view rather than design view by default:

  1. In the Visual Studio Options dialog, click HTML Designer.
  2. In the Visual Studio Options dialog, for Start pages in, select Source View.

If you use Jetbrains ReSharper, then pressing CTRL-F12 provides update the list of methods and fields above the editing pane. To disable the Visual Studio navigation bar that provides equivalent functionality, or if you do not use the Visual Studio navigation bar:

  1. In the Visual Studio Options dialog, expand Text Editor, and then click C#.
  2. In the Visual Studio Options dialog, disable the Navigation bar.

You may want to hide the Sitecore Rocks start page as well.

Optimize Content Editor Performance

You can take a number of small steps to tune the Content Editor. You can use a loggingin [sic] pipeline processor to apply configuration that applies configuration to improve performance when a user first authenticates or each time they authenticate. As this is only in your development environment, you can comment and change lines of code to enable and disable features as you see fit.

Disable Code Access Security Publisher Evidence

You may see a performance improvement if you add the following element within the /configuration/runtime element in the maching.config file (*NOT* the web.config file or a Web.config include file).

<generatePublisherEvidence enabled="false"/>

Disable Performance Counters

When you are not using them for diagnostics or otherwise, you can disable performance counters with a Web.config include file such as the following:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <setting name="Counters.Enabled">
      <patch:attribute name="value">false</patch:attribute>
    </setting>
  </sitecore>
</configuration>

Separate Log Files into Subdirectories

This is really more about convenience than performance. I generally find myself working with the main Sitecore log files and ignoring the request. Particularly because ASP.NET does not immediately free log files for deletion, the extra log files get in the way. I think it is worth updating the contents of the /configuration/log4net/appender named LogFileAppender to put all but the main log files in a separate subdirectory. Because the /configuration/log4net/appender element is not within the /configuration/sitecore element, you cannot use a Web.config include file to implement this change.

...
<file value="$(dataFolder)/otherlogs/WebDAV.log.{date}.txt"/>
...
<file value="$(dataFolder)/otherlogs/Search.log.{date}.txt"/>
...
<file value="$(dataFolder)/otherlogs/Crawling.log.{date}.txt"/>
...
<file value="$(dataFolder)/otherlogs/Publishing.log.{date}.txt"/>
...
<file value="$(dataFolder)/otherlogs/Fxm.log.{date}.txt"/>
...

Go Experimental with Process Priority

You can set the priority of the w3wp.exe process through the Task Manager, with the wmic command line tool, or in code. Because I believe that CPU is less likely to be a bottleneck at application initialization than I/O, for most developers, this will likely have no perceptible effect, at least on initialization. The first time I manually set the priority of the w3wp.exe processes to Realtime, it seemed to make a significant impact, I thought on precompilation. Since then, my results have been inconsistent, and possibly even negative. Additionally, I have received advice against changing process priority. Additionally, it seems that the w3wp.exe process can only escalate its own priority to high, whether using the command line or the API. Not to mention that we probably want to set the priority for csc.exe as well.

Here is an pipeline processor that tries to do some of this for us.

namespace SitecoreJohn.Pipelines.Initialize
{
  using System;
  using System.Diagnostics;
  using System.Timers;
 
  using Sitecore.Pipelines;
 
  public class SetProcessPriority
  {
    // <initialiez> should only get called once
    // so we should be able to use fields
    Timer _timer;
 
    public void Process(PipelineArgs args)
    {
      System.Diagnostics.Process.GetCurrentProcess().PriorityClass =
        ProcessPriorityClass.RealTime;
      _timer = new Timer(50);
      _timer.Elapsed += Invoke;
      _timer.Enabled = true;
    }
 
    private void Invoke(Object source, ElapsedEventArgs e)
    {
      foreach(Process csc in
        System.Diagnostics.Process.GetProcessesByName("csc.exe"))
      {
        csc.PriorityClass = ProcessPriorityClass.RealTime;
      }
    }
  }
}

And, of course, a Web.config include file.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <initialize>
        <processor
          patch:before="processor[1]"
          type="SitecoreJohn.Pipelines.Initialize.SetProcessPriority,SitecoreJohn" />
      </initialize>
    </pipelines>
  </sitecore>
</configuration>

Disable Health and Memory Monitors

After I published the first draft of this post, Kam Figy told me that Alex Shyba had suggested disabling the memory monitory hook. Like performance counters, there may be times when you want to enable the health and memory monitors. Otherwise, you can disable them with a Web.config include file.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <hooks>
      <hook
        type="Sitecore.Diagnostics.HealthMonitorHook, Sitecore.Kernel">
        <patch:delete />
      </hook>
      <hook
        type="Sitecore.Diagnostics.MemoryMonitorHook, Sitecore.Kernel">
        <patch:delete />
      </hook>
    </hooks>

Ignore Children When Rendering Trees

When rendering trees, a plus icon appears next to each item that has one or more children. Avoiding the check for children to determine whether or not to render this icon can improve performance when rendering trees. You can use a Web.config include file such as the following to change the ContentEditor.CheckHasChildrenOnTreeNodes setting.

<configuration
  xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <setting
        name="ContentEditor.CheckHasChildrenOnTreeNodes">
        <patch:attribute
          name="value">false</patch:attribute>
      </setting>
    </settings>
  </sitecore>
</configuration>

Conclusion

There are countless things you can do that could shave additional startup and request processing time, such as disabling irrelevant Web.config include files, removing processors from the initialize and httpRequestBegin pipelines, and otherwise. Almost anything that improves performance and/or scalability of IIS, ASP.NET, Visual Studio, the underlying data storage technologies such as SQL Server and Mongo, or otherwise in a non-development environment is likely to improve performance in development environments. Some techniques apply to specific scenarios, such as disabling indexing and using a bulk import context to improve content import performance.

If you have additional suggestions to optimize Sitecore for developers, please comment on this blog post.

Resources