Improving DataSet Serialization and Remoting Performance

MORE INFORMATION

<script type="text/javascript">loadTOCNode(1, 'moreinformation');</script>
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:
http://msdn.microsoft.com/msdnmag/issues/02/12/cuttingedge (http://msdn.microsoft.com/msdnmag/issues/02/12/cuttingedge)
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:
Download Download the SurrogateSample.exe package now. (http://download.microsoft.com/download/2/8/2/28275f15-5a26-41aa-9bd8-80972c699d17/surrogatesample.exe) 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 (http://support.microsoft.com/kb/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
<script type="text/javascript">loadTOCNode(3, 'moreinformation');</script>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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值