CSS SQL Server Engineers

This is the official team Web Log for Microsoft Customer Service and Support (CSS) SQL Support. Posts are provided by the CSS SQL Escalation Services

High waits on CLR_MANUAL_EVENT and CLR_AUTO_EVENT

High waits on CLR_MANUAL_EVENT and CLR_AUTO_EVENT

Rate This
  • Comments 4

If you have a SQL CLR application, you may notice that waits on CLR_MANUAL_EVENT and CLR_AUTO_EVENT from sys.dm_os_wait_stats are very high.

This is normal and can be safely ignored because these waits reflect internal CLR runtime waits under normal conditions.  Since SQL as a CLR host implements synchronization mechanism, it is able to track these kinds of waits and exposes them via DMV. 

The only exception when you need to pay attention to these two wait types is that you actually use unsafe assemblies and use CLR Event objects (ManualResetEvent or AutoResetEvent) yourself.  In other words, if you use ManualResetEvent and you code results in waiting on the object, the wait time will also be reflected in CLR_MANUAL_EVENT type.  The same is true for AutoResetEvent which will be reflected in CLR_AUTO_EVENT type.  But using these two objects will require explicitly creating the assembly in unsafe mode.  

To summarize, if all your assemblies are created in safe mode and you see high waits on CLR_MANUAL_EVENT and CLR_AUTO_EVENT, you can safely ignore them.

Jack Li
Escalation Engineer

Leave a Comment
  • Please add 1 and 2 and type the answer here:
  • Post
  • I've was reviewing wait stats the other day and kept finding this wait stat peaking out the other wait

  • I've was reviewing wait stats the other day and kept finding this wait stat peaking out the other wait stats by a few hundred milliseconds. Oh my! Should I care or not... well long story short is that if all of the CLR assemblies are created in safe mode

  • This is good information, but it lacks specifics.  Q1 has no rows returned, while Q2 has 2 rows returned.  This implies the CLR assemblies that are active come from Microsoft and are shipped with SQL Server 2012.  So my wait type "CLR_AUTO_EVENT" is in fact the top wait type with 13.27% of the total wait time.  Is there a specific number that would be considered bad?  For instance, if it was showing 53% of the total wait time, would that be bad?  

    Also, while other people might be satisfied with "To summarize, if all your assemblies are created in safe mode and you see high waits on CLR_MANUAL_EVENT and CLR_AUTO_EVENT, you can safely ignore them.", I have to wonder why this general statement is true?   What are the specific facts behind this general statement?

    Q1. select * from sys.dm_clr_loaded_assemblies

    Q2. select * from sys.dm_clr_tasks

  • Note that if you see CLR_MANUAL_EVENT wait from sys.dm_exec_requests, this will cause perf issues.

    Please apply hotfix support.microsoft.com/default.aspx

    and look into this blog: blogs.msdn.com/.../a-performance-issue-involving-clr-garbage-collection-and-sql-cpu-affinity-setting.aspx

Page 1 of 1 (4 items)