![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello Trond, I have read your article (and newsgroup discussion) and have experimented with your code. I think I have found a problem in your code : If I use it as you provided it, I do not get all data at the other side of the remoting : I get the data for the last complete batch of 500 items + data for the extra non complete batch. In the extract below, should not the line marked as "//<<< THIS LINE" be where "//<<< HERE" is ? ... public void GetObjectData(SerializationInfo info, StreamingContext context){ int batchSize = 500; info.AddValue("Count", (Int32)this.Count); info.AddValue("BatchSize", (Int32)batchSize); ChapterInfo[] chaptersT = new ChapterInfo[batchSize]; //<<< THIS LINE int next = 0; for (int i = 0; i < InnerList.Count / batchSize; i++) { for (int j = 0; j < batchSize; j++) { //<<< HERE chaptersT[j] = (ChapterInfo)InnerList[i*batchSize + j]; } info.AddValue(i.ToString(), chaptersT); next = i + 1; } ... I think that you are adding (InnerList.Count/batchSize) times the same chaptersT object to info, and hence you are not pulling the 60000 items over the link, only 500 + the number of items in the incomplete batch. Please check this and let me know. Greetings from Belgium. Geert Depickere "Peter Morris" <support (AT) _nospam_droopyeyes (DOT) com> wrote in message news:u$0iTy#ODHA.2788 (AT) TK2MSFTNGP10 (DOT) phx.gbl... http://www.howtodothings.com/showart...sp?article=611 |
#3
| |||
| |||
|
|
This is exactly the results that I saw as well. If you create a new array of objects for every batch, the data is serialized correctly but (as you would expect), the code takes alot longer to execute. I believe the batch approach does improve upon a single large array though. In the end, to improve DataTable transport, I changed the BinaryDataTable example from MSDN to serialize all of the rows to StringBuilder object and then placed the single string in the stream. I left the columns as indivdual objects Instead of using verbose XML (as the DataTable object does itself), I just used commas and pipes to seperate the row data. While not as fast as SQLCLient, it was a dramatic improvement over serializing each row as an array of objects. YMMV brian "Geert Depickere" <x.x (AT) xnospamx (DOT) x> wrote Hello Trond, I have read your article (and newsgroup discussion) and have experimented with your code. I think I have found a problem in your code : If I use it as you provided it, I do not get all data at the other side of the remoting : I get the data for the last complete batch of 500 items + data for the extra non complete batch. In the extract below, should not the line marked as "//<<< THIS LINE" be where "//<<< HERE" is ? ... public void GetObjectData(SerializationInfo info, StreamingContext context){ int batchSize = 500; info.AddValue("Count", (Int32)this.Count); info.AddValue("BatchSize", (Int32)batchSize); ChapterInfo[] chaptersT = new ChapterInfo[batchSize]; //<<< THIS LINE int next = 0; for (int i = 0; i < InnerList.Count / batchSize; i++) { for (int j = 0; j < batchSize; j++) { //<<< HERE chaptersT[j] = (ChapterInfo)InnerList[i*batchSize + j]; } info.AddValue(i.ToString(), chaptersT); next = i + 1; } ... I think that you are adding (InnerList.Count/batchSize) times the same chaptersT object to info, and hence you are not pulling the 60000 items over the link, only 500 + the number of items in the incomplete batch. Please check this and let me know. Greetings from Belgium. Geert Depickere "Peter Morris" <support (AT) _nospam_droopyeyes (DOT) com> wrote in message news:u$0iTy#ODHA.2788 (AT) TK2MSFTNGP10 (DOT) phx.gbl... http://www.howtodothings.com/showart...sp?article=611 |
#4
| |||
| |||
|
|
Brian, Thanks for the confirmation! About the BinaryDataTable article : I experimented with this also, because I was having problems with serializing very large datasets. My main problem was the HUGE memory consumption of the remoting server process (windows service) (and the long time it takes to serialize). I managed to solve both problems (reasonable memory usage + performance) by making a BinaryDataSet class that takes serialization in its own hands. I just serialize the dataset to a StringBuilder (through a StringWriter, a XmlTextWriter (WriteStartDocument and WriteXml) and then add the ToString() of the StringBuilder to the SerializationInfo. "Brian Flood" <bFlood (AT) spatialDataLogic (DOT) com> wrote in message news:a161d0c7.0307010851.79d0e981 (AT) posting (DOT) google.com... This is exactly the results that I saw as well. If you create a new array of objects for every batch, the data is serialized correctly but (as you would expect), the code takes alot longer to execute. I believe the batch approach does improve upon a single large array though. In the end, to improve DataTable transport, I changed the BinaryDataTable example from MSDN to serialize all of the rows to StringBuilder object and then placed the single string in the stream. I left the columns as indivdual objects Instead of using verbose XML (as the DataTable object does itself), I just used commas and pipes to seperate the row data. While not as fast as SQLCLient, it was a dramatic improvement over serializing each row as an array of objects. YMMV brian "Geert Depickere" <x.x (AT) xnospamx (DOT) x> wrote in message news:<eGkN1Q7PDHA.2424 (AT) tk2msftngp13 (DOT) phx.gbl>... Hello Trond, I have read your article (and newsgroup discussion) and have experimented with your code. I think I have found a problem in your code : If I use it as you provided it, I do not get all data at the other side of the remoting : I get the data for the last complete batch of 500 items + data for the extra non complete batch. In the extract below, should not the line marked as "//<<< THIS LINE" be where "//<<< HERE" is ? ... public void GetObjectData(SerializationInfo info, StreamingContext context){ int batchSize = 500; info.AddValue("Count", (Int32)this.Count); info.AddValue("BatchSize", (Int32)batchSize); ChapterInfo[] chaptersT = new ChapterInfo[batchSize]; //<<< THIS LINE int next = 0; for (int i = 0; i < InnerList.Count / batchSize; i++) { for (int j = 0; j < batchSize; j++) { //<<< HERE chaptersT[j] = (ChapterInfo)InnerList[i*batchSize + j]; } info.AddValue(i.ToString(), chaptersT); next = i + 1; } ... I think that you are adding (InnerList.Count/batchSize) times the same chaptersT object to info, and hence you are not pulling the 60000 items over the link, only 500 + the number of items in the incomplete batch. Please check this and let me know. Greetings from Belgium. Geert Depickere "Peter Morris" <support (AT) _nospam_droopyeyes (DOT) com> wrote in message news:u$0iTy#ODHA.2788 (AT) TK2MSFTNGP10 (DOT) phx.gbl... http://www.howtodothings.com/showart...sp?article=611 |
#5
| |||
| |||
|
|
Hello Trond, I have read your article (and newsgroup discussion) and have experimented with your code. I think I have found a problem in your code : If I use it as you provided it, I do not get all data at the other side of the remoting : I get the data for the last complete batch of 500 items + data for the extra non complete batch. In the extract below, should not the line marked as "//<<< THIS LINE" be where "//<<< HERE" is ? ... public void GetObjectData(SerializationInfo info, StreamingContext context){ int batchSize = 500; info.AddValue("Count", (Int32)this.Count); info.AddValue("BatchSize", (Int32)batchSize); ChapterInfo[] chaptersT = new ChapterInfo[batchSize]; //<<< THIS LINE int next = 0; for (int i = 0; i < InnerList.Count / batchSize; i++) { for (int j = 0; j < batchSize; j++) { //<<< HERE chaptersT[j] = (ChapterInfo)InnerList[i*batchSize + j]; } info.AddValue(i.ToString(), chaptersT); next = i + 1; } ... I think that you are adding (InnerList.Count/batchSize) times the same chaptersT object to info, and hence you are not pulling the 60000 items over the link, only 500 + the number of items in the incomplete batch. Please check this and let me know. Greetings from Belgium. Geert Depickere "Peter Morris" <support (AT) _nospam_droopyeyes (DOT) com> wrote in message news:u$0iTy#ODHA.2788 (AT) TK2MSFTNGP10 (DOT) phx.gbl... http://www.howtodothings.com/showart...sp?article=611 |
#6
| |||
| |||
|
|
Hello Yes, that's confirmed. I'm actually been looking at this with real life data the last couple of days, and have found a bug or two. The code added at the end is working as it should, you should however read my "very soon to come" input here about a annoying problem with serialized collections in combination with objects that implements the ISerializable interface. According to my futher speed tests, it is also indications that the speed problem is mutch less severe when acting with real life data (not generated), likely because realtime data supplies mutch better hash values. regards, TEK //I have tested around with the IDeserializationCallback interface, but just ignore that code (it's commented out, so it should not be a problem) [Serializable] public class BaseCollection : System.Collections.CollectionBase, ICloneable, ISerializable/*, IDeserializationCallback*/{ //private object[] _deserializationHelper = null; public BaseCollection(){ } protected BaseCollection(SerializationInfo info, StreamingContext context) : base() { int batchSize = info.GetInt32("BatchSize"); int count = info.GetInt32("Count"); int numBatches = count/batchSize; if(count%batchSize != 0) numBatches += 1; if(count > 0){ Type t = (Type)info.GetValue("type", typeof(Type)); //_deserializationHelper = new object[count]; for(int i = 0; i < numBatches; i++){ object[] obj = (object[])info.GetValue(i.ToString(),typeof(object[])); for(int j = 0; j < obj.Length; j++){ //_deserializationHelper[(i * batchSize) + j] = obj[j]; InnerList.Add(obj[j]); } } } } /* public virtual void OnDeserialization(Object sender) { // After being deserialized, initialize the m_area field // using the deserialized m_radius value. InnerList.AddRange(_deserializationHelper); _deserializationHelper = null; } */ public virtual void GetObjectData(SerializationInfo info, StreamingContext context){ int batchSize = 500; info.AddValue("Count", (Int32)this.Count); info.AddValue("BatchSize", (Int32)batchSize); if(this.Count > 0){ Type t = this[0].GetType(); info.AddValue("type", t); object[] objectT = null; int next = 0; for (int i = 0; i < InnerList.Count / batchSize; i++) { objectT = new object[batchSize]; for (int j = 0; j < batchSize; j++) { objectT[j] = InnerList[i*batchSize + j]; } info.AddValue(i.ToString(), objectT); next = i + 1; } objectT = new object[InnerList.Count - ((InnerList.Count / batchSize) * batchSize)]; // Serialize the incomplete batch. if (objectT.Length > 0) { for (int i = (InnerList.Count / batchSize) * batchSize, j = 0; i InnerList.Count; i++, j++) { objectT[j] = InnerList[i]; } info.AddValue(next.ToString(), objectT); } } } "Geert Depickere" <x.x (AT) xnospamx (DOT) x> skrev i melding news:eGkN1Q7PDHA.2424 (AT) tk2msftngp13 (DOT) phx.gbl... Hello Trond, I have read your article (and newsgroup discussion) and have experimented with your code. I think I have found a problem in your code : If I use it as you provided it, I do not get all data at the other side of the remoting : I get the data for the last complete batch of 500 items + data for the extra non complete batch. In the extract below, should not the line marked as "//<<< THIS LINE" be where "//<<< HERE" is ? ... public void GetObjectData(SerializationInfo info, StreamingContext context){ int batchSize = 500; info.AddValue("Count", (Int32)this.Count); info.AddValue("BatchSize", (Int32)batchSize); ChapterInfo[] chaptersT = new ChapterInfo[batchSize]; //<<< THIS LINE int next = 0; for (int i = 0; i < InnerList.Count / batchSize; i++) { for (int j = 0; j < batchSize; j++) { //<<< HERE chaptersT[j] = (ChapterInfo)InnerList[i*batchSize + j]; } info.AddValue(i.ToString(), chaptersT); next = i + 1; } ... I think that you are adding (InnerList.Count/batchSize) times the same chaptersT object to info, and hence you are not pulling the 60000 items over the link, only 500 + the number of items in the incomplete batch. Please check this and let me know. Greetings from Belgium. Geert Depickere "Peter Morris" <support (AT) _nospam_droopyeyes (DOT) com> wrote in message news:u$0iTy#ODHA.2788 (AT) TK2MSFTNGP10 (DOT) phx.gbl... http://www.howtodothings.com/showart...sp?article=611 |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |