Tag Archive for Performance

Performance Monitoring Class

Thought I’d share a class I use for performance monitoring to help identify areas of code that are causing bottlenecks or take a lengthy time to execute.

In SharePoint we can use the SPMonitoredScope class to wrap areas of code that we want to be monitored.

using (new SPMonitoredScope("SharePoint Performance"))
{
	// SharePoint related code
	//
}

This will output performance logging statistics to the developer dashboard (if enabled) and to the ULS.

For general SharePoint performance logging, SPMonitoredScope is ideal but it only logs methods calls to the SharePoint databases. The class I developed allows you to monitor any method, whether it’s SharePoint related or not.
Read more

Slow Query Duration

When working with custom code that manipulates lists that contain a large number of fields, the ULS logs will likely be littered with the following entries:

A large block of literal text was sent to sql. This can result in blocking in sql and excessive memory use on the front end. Verify that no binary parameters are being passed as literals, and consider breaking up batches into smaller components. If this request is for a SharePoint list or list item, you may be able to resolve this by reducing the number of fields.

followed by:
Slow Query Duration: [time in milliseconds]

then:
Slow Query StackTrace-Managed: [complete stack trace]

Note: This one’s important as you can look at the stack and identify the exact area of code that initiates the slow query log entries.

and finally:
SqlCommand: [SQL statement responsible for the log entry]
Read more

Follow

Get every new post delivered to your Inbox

Join other followers: