StyleCop very slow on TeamCity

Jun 24, 2012 at 8:02 PM

Hi together,

since we installed one of the newer StyleCop-Builds, our Build-Process on TeamCity (CI-Server) is slowed down extemely. According to the live-logs, it hangs frequently in StyleCop.

A thread-dump shows:

Thread id=892
at System.Threading.Monitor.Wait(System.Object obj, System.Int32 millisecondsTimeout, System.Boolean exitContext) 
at StyleCop.Countdown.Wait() 
at StyleCop.StyleCopCore.RunWorkerThreads(StyleCop.StyleCopThread+Data data, System.Int32 count) 
at StyleCop.StyleCopCore.Analyze(System.Collections.Generic.IList<StyleCop.CodeProject> projects, System.Boolean ignoreCache, System.String settingsPath) 
at StyleCop.StyleCopCore.Analyze(System.Collections.Generic.IList<StyleCop.CodeProject> projects) 
at StyleCop.StyleCopConsole.Start(System.Collections.Generic.IList<StyleCop.CodeProject> projects, System.Boolean fullAnalyze) 
at StyleCop.StyleCopTask.Execute() 
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask, System.Boolean& taskResult) 
at Microsoft.Build.BackEnd.TaskBuilder.InitializeAndExecuteTask(Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask, System.Boolean& taskResult) 
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteBucket(Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask, System.Collections.Generic.Dictionary<System.String, System.String> lookupHash) 
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(Microsoft.Build.BackEnd.TaskExecutionMode mode, Microsoft.Build.BackEnd.Lookup lookup) 
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(Microsoft.Build.BackEnd.Logging.TargetLoggingContext loggingContext, Microsoft.Build.BackEnd.BuildRequestEntry requestEntry, Microsoft.Build.BackEnd.ITargetBuilderCallback targetBuilderCallback, Microsoft.Build.Execution.ProjectTargetInstanceChild taskInstance, Microsoft.Build.BackEnd.TaskExecutionMode mode, Microsoft.Build.BackEnd.Lookup inferLookup, Microsoft.Build.BackEnd.Lookup executeLookup) 
at Microsoft.Build.BackEnd.TargetEntry.ProcessBucket(Microsoft.Build.BackEnd.ITaskBuilder taskBuilder, Microsoft.Build.BackEnd.Logging.TargetLoggingContext targetLoggingContext, Microsoft.Build.BackEnd.TaskExecutionMode mode, Microsoft.Build.BackEnd.Lookup lookupForInference, Microsoft.Build.BackEnd.Lookup lookupForExecution) 
at Microsoft.Build.BackEnd.TargetEntry.ExecuteTarget(Microsoft.Build.BackEnd.ITaskBuilder taskBuilder, Microsoft.Build.BackEnd.BuildRequestEntry requestEntry, Microsoft.Build.BackEnd.Logging.ProjectLoggingContext projectLoggingContext) 
at Microsoft.Build.BackEnd.TargetBuilder.ProcessTargetStack(Microsoft.Build.BackEnd.ITaskBuilder taskBuilder) 
at Microsoft.Build.BackEnd.TargetBuilder.BuildTargets(Microsoft.Build.BackEnd.Logging.ProjectLoggingContext loggingContext, Microsoft.Build.BackEnd.BuildRequestEntry entry, Microsoft.Build.BackEnd.IRequestBuilderCallback callback, System.String[] targetNames, Microsoft.Build.BackEnd.Lookup baseLookup) 
at Microsoft.Build.BackEnd.RequestBuilder.BuildProject() 
at Microsoft.Build.BackEnd.RequestBuilder.BuildAndReport() 
at Microsoft.Build.BackEnd.RequestBuilder.RequestThreadProc() 
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object state) 
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean ignoreSyncCtx) 
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) 
at System.Threading.ThreadHelper.ThreadStart() 
U-->M

Maybe others have the same problem and might need a solution aswell.

Regards,
Sascha 

Coordinator
Jun 25, 2012 at 9:41 PM
Edited Jul 4, 2012 at 4:37 PM
Which build of stylecop please?
Can you open a work item and attach the code in a zip file that reproduces the problem please


~A.
Sep 13, 2012 at 3:36 PM

Hi Andyr,

we've just tried some old versions of StyleCop.
Version 4.7.6.0 is VERY SLOW, while 4.7.4.0 is perfectly fast.

Maybe that gives you some clue, what the problem could be.

Regards,
Sascha

Coordinator
Sep 13, 2012 at 3:56 PM

Changes in those versions were:

4.7.6.0 (15cace27d8af)
=======================
Handle the lifetime of R# better for restting and checking options.
Fix R# exception where duplicate keys were trying to be added to the highlight registering.
Move MaxViolationCount into the settings file.
Fix to ensure the naming policies are checked correctly and then reset.
Update version number.


4.7.5.0 (c9385bbc21dc)
=======================
Resources for R#6.0 plugin were not loading.
dll naming had changed for R#5.1 dll support.
Styleing fixes.
Adding a new option to disable analysis as you type completely.
Update to version 4.7.5.0


4.7.4.0 (a2c3df6a8e0e)
=======================
Fix for 7105.
Fix for 7124.
Fix for 7086 for R#5.1 , R#6.0 and R#6.1 addins.
Fix for 7068.
Update version to 4.7.4.0

 

But I can't see anything straight off that it could be. 

Sep 13, 2012 at 4:07 PM

4.7.5.0 is also VERY SLOW, must be something in this build.

Coordinator
Sep 14, 2012 at 9:17 AM

So you're definately sure that 4.7.4.0 is very fast and 4.7.5.0 is very slow? Only looking at the changes in those Im finding it very difficult to see what it could be. There was a change to the auto-update version checker. Maybe its that. In your Settings.StyleCop file make sure you have:

<StyleCopSettings Version="105">
  <GlobalSettings>
    <BooleanProperty Name="AutoCheckForUpdate">False</BooleanProperty>
  </GlobalSettings>
</StyleCopSettings>

Sep 14, 2012 at 9:45 AM

We've changed the useraccount whichTeamCity's BuildAgent uses from System to local\Administrator.

Now everything is running fine - including the newest 4.7.36.0 build! :-)