Improving DataSet Serialization and Remoting Performance

转载 2006年05月21日 15:26:00


When you pass a System.Data.DataSet object between processes, .NET Framework Remoting is used to serialize, to transport, and to deserialize the DataSet class. If you pass a DataSet class back from a .NET Web Service, internally the Microsoft .NET Framework System.Xml.Serialization.XMLSerializer class is used to serialize the DataSet data back to the client. If you pass a DataSet back from a managed object that is hosted in COM+, the BinaryFormatter class is used by .NET Framework Remoting. Regardless of the remoting mechanism that is used by the .NET Framework, the DataSet class always converts the internal data to XML when serializing the data.

The DataSet class that is included with the Microsoft .NET Framework 1.0 and with the .NET Framework 1.1 works efficiently for serializing small amounts of data (hundreds of rows) in the DataSet over .NET Framework Remoting. The serialization mechanism is inefficient with a larger DataSet (thousands of rows) and incurs large transient (short lived) memory allocations. These memory allocations reduce application scalability.

Note A transient memory allocation is a short-lived memory allocation that occurs during the processing of some sections of code. Therefore, during the serialization, during the remoting, and during the deserialization of a DataSet class, various managed objects are allocated and deallocated internally by .NET Framework Remoting to process the remoting request. Allocating and deallocating larger and larger managed objects puts additional pressure on the .NET memory management system and reduces overall scalability. For example, an application that has many in-flight method invocations that generate large transient memory allocations can run out of memory before completing all the method calls.

You can greatly improve serialization and remoting performance for larger DataSets by using a correctly designed surrogate type or serialization wrapper classes. For more information about using a surrogate mechanism or a wrapper mechanism (or both) with the .NET Framework DataSet class, visit the following Microsoft Developer Network (MSDN) Web site: (
However, this article does not provide a complete sample of how to implement a DataSet surrogate type or a serialization wrapper class.

This article contains a sample serialization wrapper class that is optimized to more efficiently serialize and deserialize larger DataSets. The class significantly reduces transient memory allocations versus remoting a typical DataSet. Large reductions in the transient memory allocations also improve remoting end-to-end time and improve scalability when using a larger DataSet.

The sample provides a serialization wrapper class that is named DataSetSurrogate. The DataSetSurrogate class is used as a wrapper class for any DataSet that you want to remote. The server component passes the DataSet that you want to the DataSetSurrogate constructor and then passes the DataSetSurrogate class back to the client. On the client side, the DataSetSurrogate.ConvertToDataSet method is used to extract the DataSet from the DataSetSurrogate class.

The DataSetSurrogate class is marked Serializable and all the fields in the DataSetSurrogate class are also serializable classes. Therefore, when you remote the DataSetSurrogate object, the remoting infrastructure automatically serializes and deserializes the DataSetSurrogate object and all its fields. The key serialization advantage of the DataSetSurrogate class over the DataSet class is that the DataSetSurrogate class serializes the data in a binary format. Serializing by using a binary format is much more efficient both in memory and CPU than the existing DataSet XML serialization format.

Note To maximize the performance benefit of this serialization wrapper class, use the .NET Framework System.Runtime.Serialization.Formatters.Binary.BinaryFormatter class when remoting. Remoting by using the .NET Framework System.Runtime.Serialization.Formatters.Soap.SoapFormatter class is not as efficient when you use the DataSetSurrogate class.

The following file is available for download from the Microsoft Download Center:
DownloadDownload the SurrogateSample.exe package now. ( For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 ( How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Access the Sample Files

Save the SurrogateSample.exe file to drive C on your computer. From there you can extract the folder structure. There is a readme file in each folder that contains additional instructions.


在 ICLR 2018 的高分论文中,有研究者表明因为历史梯度平方的滑动平均值,Adam 等算法并不能收敛到最优解,因此它在泛化误差上可能要比 SGD 等方法差。最近 Salesforce 的研究者提...
  • Uwr44UOuQcNsUQb60zk2
  • Uwr44UOuQcNsUQb60zk2
  • 2017年12月27日 06:47
  • 241

The Paris Dataset图像检索数据集

The Paris Dataset James Philbin and Andrew Zisserman  Overview The Paris Dataset consists of 64...
  • GarfieldEr007
  • GarfieldEr007
  • 2016年05月14日 12:49
  • 1427

improving sql server performance

Improving SQL Server Performance   Retired Content This content is outd...
  • screaming
  • screaming
  • 2016年04月06日 15:11
  • 373

Improving the performance of JDeveloper 11g

Hi All, I recently was in Madrid with a collegue from our US Development HQ and he shared with me a...
  • luyushuang
  • luyushuang
  • 2011年10月08日 09:59
  • 578

Improving Snort performance with Barnyard

zz from: ...
  • fxismonk
  • fxismonk
  • 2016年01月21日 17:49
  • 217

Improving Database Performance with Partitioning

 Improving Database Performance with PartitioningA few years ago, I wrote an article entitled "The F...
  • ArduousBonze
  • ArduousBonze
  • 2008年08月25日 15:27
  • 518

Improving SQL Server Performance Improving .NET Application Performa...
  • lk5423968
  • lk5423968
  • 2013年12月29日 14:23
  • 885

improving Gradle build performance

Gradle, the new build system for Android projects, has been designed for scalability and efficiency....
  • x359981514
  • x359981514
  • 2014年11月04日 10:22
  • 2330

Improving 3D performance in WPF
  • yunzaitian163
  • yunzaitian163
  • 2012年02月21日 21:06
  • 406

Improving Layout Performance

分任务原文链接: 作者:长剑耿介 完成时间:2012年08月...
  • JiezhiG
  • JiezhiG
  • 2015年01月12日 14:24
  • 487
您举报文章: Improving DataSet Serialization and Remoting Performance