ADO.NET performance improvements with the .NET Framework 2.0 SP1

Published 28 January 08 05:50 PM | dpblogs 

With the release of Visual Studio 2008 and the .NET Framework 2.0 SP1, there are some bug fixes and improvements in ADO.NET (A list of the general fixes is at http://support.microsoft.com/kb/945757)

We worked with the CLR team to get improvements like the thread pool improved scalability, and that was important for making sure our SqlReader performance is better in multithreaded scenarios (like your ASP.NET applications under load).

Particularly improved were scenarios like Data set insertion, and multi-threaded scenarios (such as ASP.NET applications) using SqlDataReader (25% better or more, depending on hardware and OS architecture).

For a complex real world web application, like Petshop, the improvement is not so big, since the application does many other things in addition to data access, but still you should get part of the benefits.

A summary of our lab numbers, just as a reference of how much improvement you can get:

Scenario .NET FW 2.0 .NET FW 2.0 SP1 Improvement
SqlReader 14855 18100 27.3%
DataSet insert 9637 12890 40.8%
Pet Shop 4.0(Browse the store) 22.44 24.40 8.72%
Pet Shop 4.0 (Buy some pets) 21.54 23.04 6.99%

* Average throughput, over a set of runs, on 4 proc dual core servers with W2K3 SP1, 16 Gb. of RAM, with a sample average load (not by far peak capacity). Hardware differences, network conditions and the way your scenario is written affect performance, among many other things, so your mileage may vary.

You can find the code for Petshop here, and here I paste a sample of code similar to our main test loop (which is run in multiple threads, by our test harness. Remember that most SqlClient classes are not thread-safe, so your code shouldn't use the same object in two different threads):

public void SqlReader() {
    using (SqlConnection conn = new SqlConnection(_connectionString)) {
        conn.Open();
        SqlCommand cmd = new SqlCommand(_sql, conn);
        using (SqlDataReader reader = cmd.ExecuteReader()) {
            int fields = reader.FieldCount;
            while (reader.Read()) {
                for (int i = 0; i < fields; i++) {
                    object obj = reader.GetValue(i);
                }
            }
        }
    }
}

public void DataSetInsert() {
    SqlConnection conn = new SqlConnection(_connectionString);
    DataSet ds = new DataSet();
    SqlDataAdapter adp = new SqlDataAdapter(_sql, conn);
    adp.Fill(ds, "atable");
}

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# ADO.NET improvements in .NET Framework 2.0 SP1 | .Net said on January 28, 2008 10:08 PM:

PingBack from http://blog.kantikalyan.com/adonet-improvements-net-framework-20-sp1/

# .NET a 2.860 m de altura said on January 28, 2008 10:59 PM:

El Service Pack 1 de .NET Framework 2.0 fue, sin muchos bombos ni platillos, liberado como parte del

# Jonathan Bruce said on January 29, 2008 11:43 AM:

Are these threading improvements just back ported from the 3.5 Framework code-base?

# Christopher_G_Lewis said on January 29, 2008 2:36 PM:

Any idea if these ADO.Net fixes would help SharePoint  (MOSS/WSS) installations?

# Jon Shern said on January 30, 2008 12:24 AM:

Ping back from

http://jonshern.com/2008/01/29/adonet-performance-improvements-with-net-framework-20-sp1/

# Mik said on January 30, 2008 8:46 AM:

Great!

But you guys could at least categorize this bug-fixing list. It is so uncool to read all these bug fixes...

Anyway, many thanks for the job you do :)

# Sam Gentile said on January 31, 2008 9:07 AM:

I was going to write a separate post on this but I will include it here. I have had the opportunity to

# DotNetKicks.com said on February 2, 2008 2:51 AM:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# Simon Brangwin said on February 3, 2008 9:04 PM:

Are these performance improvements to the ADO.NET core or just the SqlClient ADO.NET provider? In other words, will our proprietary ADO.NET data provider benefit from SP1?

# Bruno Guardia (MSFT) said on February 4, 2008 12:47 PM:

The improvements come part from each component: the .NET CLR, core ADO.Net and SqlClient. While I cannot talk for a specific proprietary data provider, probably you will get at least part of the benefits in similar scenarios.

# OPC Diary said on February 5, 2008 5:45 PM:

SP1においてスレッドプール周りの見直し等によりパフォーマンスが改善されたという...

# Hot Topics said on February 7, 2008 3:05 PM:

Two great posts appeared recently on the ADO.NET team blog. The first details some of the performance

Leave a Comment

(required) 
(optional)
(required) 
Page view tracker